In my code some variables are getting negative values, I want to make minimum as zero, therefore when they get negative values I want them to assign them zero value.HOW to do it?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
KAPIL MAMTANI
am 9 Mai 2016
Kommentiert: KAPIL MAMTANI
am 10 Mai 2016
In my code some variables are getting negative values, I want to make minimum as zero, therefore when they get negative values I want them to assign them zero value.The variables are N and P. I want whenever N or P goes negative than if N or P <=0 than N or P = 0 and Gp = 0. I am unable to do so in my for loop. Need Assistance!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Mai 2016
N = max(0, N);
4 Kommentare
Walter Roberson
am 10 Mai 2016
You wrote,
"I want to make minimum as zero, therefore when they get negative values I want them to assign them zero value"
Add the line N = max(0,N) at the point at which you want to make the negative numbers into 0.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!