Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. % Clear the Command Window and Workspace and close any open figures
  2. clear;
  3. clc;
  4. close all;
  5.  
  6. % Define viewing size and step size
  7. x1 = -5:0.01:-1.01;
  8. x2 = -0.99:0.01:0.99;
  9. x3 = 1.01:0.01:5;
  10. y = -5:0.01:5;
  11.  
  12. % Other variables
  13. V = 100;
  14. R = 1;
  15. Q = 3/2 * R * V;
  16.  
  17. % Create meshgrids
  18. [X1, Y1] = meshgrid(x1, y);
  19. [X2, Y2] = meshgrid(x2, y);
  20. [X3, Y3] = meshgrid(x3, y);
  21.  
  22. % Calculate (nondimensionalized) thetas
  23. theta1_1 = atan((Y1/R) ./ (X1/R + R));
  24. theta2_1 = -atan((Y1/R) ./ (X1/R - R));
  25. theta1_2 = atan((Y2/R) ./ (X2/R + R));
  26. theta2_2 = -atan((Y2/R) ./ (X2/R - R));
  27. theta1_3 = atan((Y3/R) ./ (X3/R + R));
  28. theta2_3 = -atan((Y3/R) ./ (X3/R - R));
  29.  
  30. % Calculate stream function
  31. psi1 = V*Y1/R + Q * (theta1_1 + theta2_1);
  32. psi2 = V*Y2/R + Q * (theta1_2 + theta2_2);
  33. psi3 = V*Y3/R + Q * (theta1_3 + theta2_3);
  34.  
  35. % Plot contours
  36. figure;
  37. hold on;
  38. [~, g] = contour(X1, Y1, psi1, 25);
  39. g.LineColor = 'black';
  40. [~, g] = contour(X2, Y2, psi2, 25);
  41. g.LineColor = 'black';
  42. [~, g] = contour(X3, Y3, psi3, 25);
  43. g.LineColor = 'black';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement