How do I plot a graph when the parameter changes?
Afficher commentaires plus anciens
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 commentaires
Sriram Tadavarty
le 27 Avr 2020
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
le 27 Avr 2020
Sriram Tadavarty
le 27 Avr 2020
Glad that it is of help.
Placing the same in the answer.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!