Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.25 KB | None | 0 0
  1. function FMM2
  2. % This program will find the maximum amplitude of u for both omega=pi
  3. % and omega= 1.5*pi from data derived via CMP in Computerlab 2 in
  4. % the course "Mathematics of Physical Models B, 10.5 ECTS" given at
  5. % UmU.
  6.  
  7. %% Loading data
  8. % u omega#(:,1) defines the geometry, u omega1(:,2:end) is the
  9. % computed data.
  10. u_omega1 = load('omega1.txt');
  11. u_omega2 = load('omega2.txt');
  12.  
  13. %% Finding maximum
  14. s = size(u_omega1);
  15. max_omega1(1) = 0;
  16. max_omega2(1) = 0;
  17. Max_omega1 = max_omega1(1);
  18. Max_omega2 = max_omega2(1);
  19. for n = 2 : s(2)
  20.     max_omega1(n) = max(abs(u_omega1(:,n)));
  21.     max_omega2(n) = max(abs(u_omega2(:,n)));
  22.    
  23.     if max_omega1(n)>Max_omega1
  24.         Max_omega1 = max_omega1(n);
  25.         MAX_n1 = n;
  26.         end
  27.    
  28.     if max_omega2(n)>Max_omega2
  29.         Max_omega2 = max_omega2(n);
  30.         MAX_n2 = n;
  31.         end
  32.     end
  33.  
  34. %% Ploting the result 35
  35. plot(u_omega1(:,1),u_omega1(:,MAX_n1),u_omega2(:,1),u_omega2(:,MAX_n2))
  36. title('Maximum amplitude for \omega= \pi and \omega=1.5 \pi', ...  
  37.     'fontsize', 11, 'fontweight', 'bold');
  38. xlabel('x−coordinate [m]');
  39. ylabel('Dependent variable');
  40. legend(['\omega= \pi ', sprintf('t=%.1f',0.1*(MAX_n1-2))],['\omega=1.5 \pi ',...
  41.     sprintf('t=%.1f',0.1*(MAX_n-2))])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement