how do i store the all 100 xmax values for the code
Show older comments
%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
Answers (1)
Star Strider
on 29 Mar 2018
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
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!