Facebook
From Violet Bee, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 264
  1. close all
  2. clear all
  3. clc
  4.  
  5. figure(1)
  6. x=linspace(-3*pi,3*pi,200);
  7. y=linspace(-2,2,200);
  8. subplot(3,3,[1,3])
  9. [X,Y]=meshgrid(x,y);
  10. Z=X.*cos(X).*abs(sin(Y).^2);
  11. N_mat(:,1)=y
  12. mesh(X,Y,Z)
  13. xlabel('x')
  14. ylabel('y')
  15. zlabel('z')
  16. colorbar
  17.  
  18. subplot(3,3,[4,7])
  19. X=-2*pi;
  20. Z=X.*cos(X).*abs(sin(y).^2);
  21. N_mat(:,2)=Z;
  22. plot(y,Z,'k')
  23. xlabel('x')
  24. ylabel('Z')
  25. legend('z=f(x,y) for x=-2*pi')
  26.  
  27.  
  28. subplot(3,3,[5,8])
  29. X=pi/2;
  30. Z=X.*cos(X).*abs(sin(y).^2);
  31. N_mat(:,3)=Z;
  32. plot(y,Z,'b')
  33. xlabel('x')
  34. ylabel('Z')
  35. legend('z=f(x,y) for x=pi/2')
  36.  
  37.  
  38. subplot(3,3,[6,9])
  39. X=2*pi;
  40. Z=X.*cos(X).*abs(sin(y).^2);
  41. N_mat(:,2)=Z;
  42. plot(y,Z,'r')
  43. xlabel('x')
  44. ylabel('Z')
  45. legend('z=f(x,y) for x=2*pi')
  46.  
  47. save N_mat
  48. xlswrite('Matrix_A.xlsx','Next Columns','Sheet','A4:A1000')
  49.  
  50. clear all
  51.  
  52. load N_mat
  53. figure(2)
  54. subplot(1,3,1)
  55. plot(N_mat(:,1),N_mat(:,1),'k')
  56. legend('Z from N_mat, for X=-2*pi')
  57.  
  58. subplot(1,3,2)
  59. plot(N_mat(:,1),N_mat(:,2),'b')
  60. legend('Z from N_mat, for X=pi/2')
  61.  
  62. subplot(1,3,3)
  63. plot(N_mat(:,1),N_mat(:,3),'r')
  64. legend('Z from N_mat, for X=2*pi')
  65.