Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: If else not working
Replies: 2   Last Post: May 4, 2013 5:30 PM

 Messages: [ Previous | Next ]
 Md. Mushfiqur Posts: 3 Registered: 4/25/13
If else not working
Posted: Apr 25, 2013 7:24 PM

I'm having some problems with a very simple if else statement.
When I am running the program, I see the Matlab is not executing the statements. I am trying to make iterations to get the value of all the variables when -0.05<Pnet<0.05. If the answer comes in range it will display all the variables, otherwise it will incerement the V and go for second iteration. When I run I see Matlab is incrementing 'V' but not recalculating the variables, instead printing the same values for the iteration.
V=3.0;

for i=0:1:300
N=151;
Tsr=(N*3.14*0.34)/(V*60);
Cp=(((-1)*0.4416*Tsr*Tsr)+(0.4342*Tsr));
Pf=(N*0.03*0.1046);
Pair=(1.212*V*V*V*0.153)/2;
Prot=N*0.03*0.1046;
Ke=0.0955;
E=Ke*N;
I=(E-13-1.4)/15;
Pe=E*I*1.04;
Pgen=Pe+Pf;
Pnet=Prot-Pgen;

if((-0.05<Pnet) && (Pnet<0.05))
display(V)
display(N)
display(Tsr)
display(Cp)
display(Pf)
display(Pair)
display(Prot)
display(Ke)
display(E)
display(I)
display(Pe)
display(Pgen)
display(Pnet)
V=V+0.01;
else
V=V+0.01;

end
end

Date Subject Author
4/25/13 Md. Mushfiqur
4/25/13 Nasser Abbasi
5/4/13 Md. Mushfiqur