How do I plot a graph when the parameter changes?

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 comentarios

Hi,
As far as i understand, you are looking for plotting the maximum value of the plot as a function of l. So, tried to place the attachment here. Please do have a look and let me know if you are looking for the same.
Thanking you.
donghun lee
donghun lee el 27 de Abr. de 2020
Yes!! This is what I have been actually looking for! Thank you soooo much for your help Sriram!!
Glad that it is of help.
Placing the same in the answer.

Iniciar sesión para comentar.

 Respuesta aceptada

Sriram Tadavarty
Sriram Tadavarty el 27 de Abr. de 2020

1 voto

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

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Abr. de 2020

Comentada:

el 27 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by