Not sure what I'm doing wrong.

1 回表示 (過去 30 日間)
Matthew Orsie
Matthew Orsie 2017 年 11 月 13 日
コメント済み: Star Strider 2017 年 11 月 13 日
%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 件のコメント
Jan
Jan 2017 年 11 月 13 日
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 2017 年 11 月 13 日
It says there an error in line 10 but I'm not sure what the error is

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2017 年 11 月 13 日
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 件のコメント
Matthew Orsie
Matthew Orsie 2017 年 11 月 13 日
Is there anyway you could show me how to plot points on the top of each curve?
Star Strider
Star Strider 2017 年 11 月 13 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by