How do I plot individual points on an existing graph

165 views (last 30 days)
%Define Values
d = [ 0.25, 0.5 , 1 , 1.5 , 2 ];
m = 1;
k = 1;
omeganought = 1;
omega = linspace (0, 2);
%Creating a graph for all damping values
for k1 = 1:length(d)
FA(k1,:) = 1 ./ sqrt ( power(m,2)*power((power(omeganought,2)-power(omega,2)),2) + power(d(k1),2)*power(omega,2));
end
%Plotting points (omega_d, M(omega_d))
%plot graph
plot (omega, FA)
%Labels
xlabel ('Frequency');
ylabel ('Frequency response');
Title ('Frequency response curve')
So, My question is asking me to plot the points (omega_d, M(omega_d)). These points represent the maximum gain for each damping factor 'd'. I think it just wants me to put points on the Max of each curve and I'm not sure how to do so. Any help is appreciated.

Accepted Answer

Star Strider
Star Strider on 13 Nov 2017
Only three have definable peaks.
That said, this works:
%Define Values
d = [ 0.25, 0.5 , 1 , 1.5 , 2 ];
m = 1;
k = 1;
omeganought = 1;
omega = linspace (0, 2);
%graph
for k1 = 1:length(d)
FA(k1,:) = 1 ./ sqrt ( power(m,2)*power((power(omeganought,2)-power(omega,2)),2) + power(d(k1),2)*power(omega,2));
[Peak{k1},Omga{k1}] = findpeaks(FA(k1,:), omega);
end
%plot graph
figure(1)
plot (omega, FA)
hold on
plot([Omga{:}], [Peak{:}], '^r', 'MarkerFaceColor','r')
hold off
I am not certain how you want to handle the last two.
  2 Comments
Star Strider
Star Strider on 13 Nov 2017
You can plot a vertical line at omega=1 with:
%plot graph
figure(1)
plot (omega, FA)
hold on
plot([Omga{:}], [Peak{:}], '^r', 'MarkerFaceColor','r')
plot([1 1], ylim, '--')
hold off
Plotting a vertical line there is a mystery to me, too, especially since the peak of the first curve is at 0.990, not 1. (It’s the second plot call in the hold block.)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!