Not sure what I'm doing wrong.

1 visualizzazione (ultimi 30 giorni)
Matthew Orsie
Matthew Orsie il 13 Nov 2017
Commentato: Star Strider il 13 Nov 2017
%Define Values
d = [ 0.25, 0.5 , 1 , 1.5 , 2 ];
m = 1;
k = 1;
omeganought = 1;
omega = linspace (0, 2);
%graph
FA = 1 / sqrt ( power(m,2)*power((power(omeganought,2)-power(omega,2)),2) + power(d,2)*power(omega,2));
%plot graph
plot (FA)
For my question, I need to plot a graph with all of those damping values ( d = o.25, 0.5, 1, 1.5 2), plugged into that function.
My question also says that I need to fit it in a window [0 , 2] by [0 , 4] and I'm not sure how to do that either. I could use some serious help for I haven't a clue about what I'm doing.
  2 Commenti
Jan
Jan il 13 Nov 2017
Start with using the "{} Code" button to format your code. Currently it is not readable and the question is not clear. What is the problem with the shown code?
Matthew Orsie
Matthew Orsie il 13 Nov 2017
It says there an error in line 10 but I'm not sure what the error is

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 13 Nov 2017
I would use a loop through the values of ‘d’, then plot:
%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));
end
%plot graph
plot (omega, FA)
  2 Commenti
Matthew Orsie
Matthew Orsie il 13 Nov 2017
Is there anyway you could show me how to plot points on the top of each curve?
Star Strider
Star Strider il 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by