필터 지우기
필터 지우기

How do I plot a graph when the parameter changes?

조회 수: 1 (최근 30일)
donghun lee
donghun lee 2020년 4월 27일
댓글: donghun lee 2020년 4월 27일
clc, clear all
k_l = 26400; %Linear stiffness
m = 483; %Mass
l =0.5;
d =-0.1;
f_n = sqrt(k_l/m)/(2*pi); %Natural frequency
Om_array = linspace(0,20,40); %in rad/s-1
A_array = linspace(0,0.06,40);
[om_array, a_array] = meshgrid(Om_array, A_array);
Response_amp = zeros(size(Om_array));
T = 130;
x0 = [0,0];
for i=1:numel(Om_array)
for j=1:numel(A_array)
Om = om_array(i,j);
A = a_array(i,j);
k_s = -(k_l*(l-d))/(4*d); %Spring stiffness
f = @(t,x) [ x(2); ...
-(2*k_s*(x(1)-(A*sin(Om*t))))* ...
(sqrt((l-d)^2 + (x(1)-(A*sin(Om*t)))^2) - l)/ ...
(m*(sqrt((l-d)^2 + (x(1)-(A*sin(Om*t)))^2))) ];
[t, x] = ode45(f,[100,T],x0);
Response_amp(i,j) = (max(x(:,1)) - min(x(:,1)))/2;
% xval(i) = Om/(2*pi) ;
end
end
%% plot
figure(1);
ax = axes();
view(3);
hold(ax);
view([30 33]);
grid on
mesh(om_array/(2*pi),a_array,Response_amp) ;
xlabel('Frequency (Hz)')
ylabel('Excitation Amplitude (m)')
zlabel('Response Amplitude (m)')
set(gca,'FontSize',17)
Hi, all. This is the code of my ode45 function. If you run this code, you will see 3d plot graph (Frequency vs Excitation ampltidue vs Response amplitude). The maximum value of response amplitude will always occur at the maximum exciation amplitude. If we change the value of the parameter "l ", the maximum response amplitude will also change.
So, I wish to plot a graph (l vs the maximum response amplitude) when l is varied from 0 to 1.
Thanks for reading.
  댓글 수: 3
donghun lee
donghun lee 2020년 4월 27일
Yes!! This is what I have been actually looking for! Thank you soooo much for your help Sriram!!
Sriram Tadavarty
Sriram Tadavarty 2020년 4월 27일
Glad that it is of help.
Placing the same in the answer.

댓글을 달려면 로그인하십시오.

채택된 답변

Sriram Tadavarty
Sriram Tadavarty 2020년 4월 27일
Hi Donghun,
This can be done by taking the maximum value of Response_amp and storing the values for each iteration of l. Then plot the maximum values with l.
Placed the same in the attachment.
Hope this helps.
Thanking you.
Regards,
Sriram
  댓글 수: 1
donghun lee
donghun lee 2020년 4월 27일
Perfect! I appreciate your help again Sriram. :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by