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 CenterFile Exchange에서 2-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