I am trying to set up the loop to run the calculation as well as save the output that way i can plot it in a graph.
clc
clear
y=0.5; %magnitude of base motion
zeta=1; %damping ratio
wb=35; %base frequency
k=4220000; %stiffness
for m=[13236 21523 5750000 10000000] %<===input mass%
wn=sqrt(k/m)
r=wb/wn
x=y*sqrt(((1+(2*zeta*r)^2)/(((1-r^2)^2)+((2*zeta*r)^2))))
T=x/y
end

 採用された回答

Star Strider
Star Strider 2020 年 5 月 14 日
編集済み: Star Strider 2020 年 5 月 14 日

0 投票

Try this:
y=0.5; %magnitude of base motion
zeta=1; %damping ratio
wb=35; %base frequency
k=4220000; %stiffness
m=[13236 21523 5750000 10000000]; %<===input mass%
for k = 1:numel(m)
wn=sqrt(k/m(k));
r=wb/wn;
x=y*sqrt(((1+(2*zeta*r)^2)/(((1-r^2)^2)+((2*zeta*r)^2))));
T(k)=x/y;
rv(k) = r;
end
figure
plot(rv, T)
grid
xlabel('r')
ylabel('T')
EDIT — Plotting ‘T’ as a function of ’r’, as requested. The ‘r’ values are saved as vector ‘rv’ in order not to disrupt the logic in the loop.
.

3 件のコメント

Jesse Ontiveros
Jesse Ontiveros 2020 年 5 月 14 日
Do you think you can make the x axis = to the output for r, rather than for m?
Jesse Ontiveros
Jesse Ontiveros 2020 年 5 月 14 日
thank you
Star Strider
Star Strider 2020 年 5 月 14 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File 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