Need help using the for loop

1 Ansicht (letzte 30 Tage)
Jose Grimaldo
Jose Grimaldo am 21 Okt. 2019
Kommentiert: David Hill am 22 Okt. 2019
Test case
Check if AdjustMinValue(4, [2, 12, 9, 20], 10) returns [4, 12, 18, 20]

Antworten (1)

David Hill
David Hill am 22 Okt. 2019
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 Kommentare
Jose Grimaldo
Jose Grimaldo am 22 Okt. 2019
Code did not work
David Hill
David Hill am 22 Okt. 2019
Works for me!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by