MATLAB Answers

0

Need help using the for loop

Asked by Jose Grimaldo on 21 Oct 2019 at 23:19
Latest activity Commented on by David Hill on 22 Oct 2019 at 3:19
Test case
Check if AdjustMinValue(4, [2, 12, 9, 20], 10) returns [4, 12, 18, 20]

  0 Comments

Sign in to comment.

1 Answer

Answer by David Hill on 22 Oct 2019 at 0:27

Not sure why you have to use a for-loop.
function dataSamples = adjustMinValue(dataSamples,minValue)
for i=1:length(dataSamples)
if dataSamples(i)<minValue
dataSamples(i)=2*dataSamples(i);
end
end

  2 Comments

Jose Grimaldo on 22 Oct 2019 at 0:48
Code did not work
David Hill on 22 Oct 2019 at 3:19
Works for me!

Sign in to comment.