How to mark the maximum points in mesh

24 visualizaciones (últimos 30 días)
Donghun Lee
Donghun Lee el 8 de Ag. de 2020
Respondida: Star Strider el 8 de Ag. de 2020
clc,clear all
k_l = 26400; %Linear stiffness
m = 483; %Mass
A = 0.025; %Excitation amplitude
d =-0.005; %Stretching condition
f_n = sqrt(k_l/m)/(2*pi); %Natural frequency
%%
Om_array = linspace(0,10*pi,40); %Excitation Frequency in rad/s-1
l_array = linspace(0,1,40); %Length of the spring
[om_array, L_array] = meshgrid(Om_array, l_array);
Response_amp = zeros(size(Om_array));
T = 150; %Time
x0 = [0,0]; %Initial condition
for i=1:numel(Om_array)
for j=1:numel(l_array)
Om = om_array(i,j);
l = L_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)))/8;
% xval(i) = Om/(2*pi) ;
end
end
%% plot
fig = figure();
ax = axes();
view(3);
hold(ax);
% view([-53 33]);
grid on
mesh(om_array/(2*pi),L_array,Response_amp,'edgecolor','k'); %Excitation frequency in Hz
xlabel('Frequency (Hz)')
ylabel('Length of the spring (m)')
zlabel('Response Amplitude (m)')
ylim([0.07 1])
zlim([0 0.3])
a = colorbar;
a.Label.String = 'Response Amplitude (m)';
set(gca,'FontSize',15)
set(gca, 'xticklabel', []);
set(gca, 'yticklabel', []);
set(gca, 'zticklabel', []);
Hi, this is my mesh function and I wish to mark the maximum points in the mesh graph as below,
Can anyone help me out on this please?
Thanks for reading.

Respuestas (1)

Star Strider
Star Strider el 8 de Ag. de 2020
Add this loop just before the mesh call:
for k = 1:size(Response_amp,1)
[Ramax(k),Idx(k)] = max(Response_amp(k,:));
Xv(k) = om_array(k,Idx(k))/(2*pi);
Yv(k) = L_array(k,Idx(k));
end
and this plot3 call after the hold call:
for k = 1:size(Response_amp,1)
[Ramax(k),Idx(k)] = max(Response_amp(k,:));
Xv(k) = om_array(k,Idx(k))/(2*pi);
Yv(k) = L_array(k,Idx(k));
end
so the complete code after the first loop is now:
%% plot
for k = 1:size(Response_amp,1)
[Ramax(k),Idx(k)] = max(Response_amp(k,:));
Xv(k) = om_array(k,Idx(k))/(2*pi);
Yv(k) = L_array(k,Idx(k));
end
fig = figure();
ax = axes();
% view(3);
hold(ax);
% view([-53 33]);
grid on
mesh(om_array/(2*pi),L_array,Response_amp,'edgecolor','k'); %Excitation frequency in Hz
xlabel('Frequency (Hz)')
ylabel('Length of the spring (m)')
zlabel('Response Amplitude (m)')
ylim([0.07 1])
zlim([0 0.3])
a = colorbar;
a.Label.String = 'Response Amplitude (m)';
set(gca,'FontSize',15)
set(gca, 'xticklabel', []);
set(gca, 'yticklabel', []);
set(gca, 'zticklabel', []);
plot3(Xv, Yv, Ramax, '^r')
view(30,30)
producing:
as desired.
.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by