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?

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!

 채택된 답변

N = max(0, N);

댓글 수: 4

Thanks Mr Walterson, Also there is Gp a variable which is checked for N/P ratio and when one of N and P gets zero it shows rank deficient error.
Also where should i place this
N = max(0, N);
in for loop for i.
Also i am getting
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in code (line 203)
I7 = [A;N;P;S;Cseq;Mi;CO2_actual] ;
plaese help
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2016년 5월 9일

댓글:

2016년 5월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by