how do i store the all 100 xmax values for the code

%there are 100 xmax values but it only displays the last xmax value as xmax in the workspace.
for w=1:1:100
t=0:0.001:10;
X=-100*w^-2*(sin(t*w));
Xmax=max(abs(X))
end

回答(1 个)

Since ‘w’ is defined as having only positive integer values, you can use it as an index.
Try this:
t=0:0.001:10;
for w=1:1:100
X = -100*w^-2*(sin(t*w));
Xmax(w) = max(abs(X));
end

类别

在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by