how do i store Xmax for this code?

% I want to make a w vs Xmax graph. The script file is attached below.
for w=1:1:100
t=0:0.001:10
X=-100*w^-2*(sin(t*w))
Xmax=max(abs(X))
end

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 3 月 28 日

0 投票

Xmax(w) = max(abs(X));

2 件のコメント

ian flanagan
ian flanagan 2018 年 3 月 28 日
it shows a 0 in every colum but the first and last. why is that
Walter Roberson
Walter Roberson 2018 年 3 月 28 日
Not when I try.
wvals = 1:1:100;
num_w = length(wvals);
Xmax = zeros(1,num_w);
t=0:0.001:10;
for widx = 1:num_w
w = wvals(widx);
X=-100*w^-2*(sin(t*w));
Xmax(widx)=max(abs(X));
end
plot(wvals, Xmax)

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

カテゴリ

ヘルプ センター および File ExchangeGraphics Objects についてさらに検索

質問済み:

2018 年 3 月 28 日

コメント済み:

2018 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by