Skip to content

Instantly share code, notes, and snippets.

@mick001
Created August 28, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mick001/23dc5a2dc01131df5cfe to your computer and use it in GitHub Desktop.
Save mick001/23dc5a2dc01131df5cfe to your computer and use it in GitHub Desktop.
Complex functions and flow around a cylinder part 1 (matlab). Full article available at: http://www.firsttimeprogrammer.blogspot.com/2015/07/complex-functions-and-flow-around.html
% Set up
x = -4:0.2:4;
y1 = -4:0.2:4;
y = (-4:0.2:4)*1i;
[X, Y]= meshgrid(x,y);
% Complex variable s
s = X + Y;
% Complex function f(z)
z = s + 1./s;
%--------------------------------------------------------------------------
% Plot the surfaces (abs(), real() and imag())
%Absolute value
figure
subplot(1,3,1);
surfc(x,y1,abs(z));
xlabel('x');ylabel('y');zlabel('z');
title('Absolute value');
%Real part
subplot(1,3,2)
surfc(x,y1,real(z));
xlabel('x');ylabel('y');zlabel('z');
title('Real part');
%Imaginary part
subplot(1,3,3)
surfc(x,y1,imag(z));
xlabel('x');ylabel('y');zlabel('z');
title('Imaginary part');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment