How to find the maximum value of the output values from a FOR loop
Show older comments
Hi,
I am trying to find the maximum value from 100 output values which are generated from a FOR loop. Essentially what my loop does is from time 't' 99 to 100 at 0.01 intervals I take readings of displacement of a sine wave. Then I convert them all to positive values and then try to find the maximum of those values, which is basically the amplitude of the wave, which is my aim here. But MaxA gives me an answer which is way too higher than the amplitude. My code is shown below. Thank you for your time.
for t=99:0.01:100
sim('massspringdamper')
ys=interp1(t,x,t);
ys=abs(ys);
[MaxA]=max(ys);
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!