Home » Posts tagged 'Matlab code'
Tag Archives: Matlab code
Swirl,Matlab Code
clc; clear all; close all; x = -20:0.1:20; sz = size(x); ind = 0; b = 6 for n = 1:15 % for i = 1:sz(2) for j = 1:sz(2) sw(i,j) = sin(b*cos(sqrt(x(i)^2+x(j)^2))-n*atan2(x(i),x(j))); end end ind = ind +1; fig = figure('Position',[0 0 800 800]); hold on; imagesc(sw); colormap bone; axis off; set(fig, 'color', [0 0 0]); set(gcf, 'InvertHardCopy', 'off'); hold off; %print(fig,['Sw',num2str(ind)],'-djpeg ','-r300'); close all; end
Henneberg surface, Matlab code
close all; clc;clear all;
[u v] = meshgrid(0:0.1:1); %v = meshgrid(1:0.01:2); i = 1; for u =-pi/2: 0.1:pi/2 j =1; for v = -pi/2:0.1:pi/2 x(i,j) = 2*sinh(u)*cos(v) - 2/3*sinh(3*u)*cos(3*v); y(i,j) = 2*sinh(u)*sin(v) - 2/3*sinh(3*u)*sin(3*v); z(i,j) = 2*cosh(2*u)* cos(2*v); j = j+1; end i = i+1; end surf(y,x,z); axis off;