Multiple elseif command not working even when condition is true
이전 댓글 표시
%% in below code for Bita =0.3 and 0.1 and 0.2 and 0.6 it is not executing inside statement however for Bita=0.4 and 0.5 only it is working please reply
Alpha = input ('Enter the value of alpha layer from 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8 = ');
x= input ('Enter the value of gamma layer from 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8 = ');
Bita=1-Alpha-x;
if Bita == 0.1
Fx =0.2065*(x^2)-1.0425*(x)+0.9486;
Fxt =Fx*2326.2; %in Mpa IM7/8552 table 1.4 barbero pg.33
Fxc =-0.1508*(x^3) + 0.1658*(x^2) - 0.8379*(x) + 0.922;
Fxc =Fxc*1200.1; %in Mpa IM7/8552 table 1.4 barbero pg.33
Fxy=0.3524*(x)+.0884;
Fxy=Fxy*1200.1; %in Mpa IM7/8552 table 1.4 barbero pg.33
elseif Bita == 0.2
Fx =-0.2797*(x^2) - .607*(x)+ 0.8112;
Fxt =Fx*2326.2; %in Mpa
Fxc =44.032*(x^6) - 103.87*(x^5) + 94.683*(x^4) - 41.999*(x^3) + 9.3574*(x^2) - 1.716*(x)+ 0.8608;
Fxc =Fxc*1200.1; %in Mpa
Fxy=0.3524*(x)+.0884;Fxy=Fxy*1200.1; %in Mpa
elseif Bita == 0.3
disp(Bita)
Fx =-.8*(x)+.74; Fxc=Fx;
Fxt = Fx*2326.2; %in Mpa
Fxc = Fxc*1200.1; %in Mpa
Fxy=.3524*(x)+.0884;Fxy=Fxy*1200.1; %in Mpa
elseif Bita == 0.4
Fx =-.6*(x-.1)+.565; Fxc=Fx;
Fxt = Fx*2326.2; %in Mpa
Fxc = Fxc*1200.1; %in Mpa
Fxy=.3524*(x)+.0884;Fxy=Fxy*1200.1; %in Mpa
elseif Bita == 0.5
Fx = -.8*(x-.1)+.475; Fxc=Fx;
Fxt = Fx*2326.2; %in Mpa
Fxc = Fxc*1200.1; %in Mpa
Fxy=.3524*(x)+.0884;Fxy=Fxy*1200.1; %in Mpa
elseif Bita == 0.6
Fx =-.8*(x-.1)+.38; Fxc=Fx;
Fxt = Fx*2326.2; %in Mpa
Fxc = Fxc*1200.1; %in Mpa
Fxy=.3524*(x)+.0884;Fxy=Fxy*1200.1; %in Mpa
elseif Bita == 0.7
Fx =-.8*(x-.1)+.284; Fxc=Fx;
Fxt = Fx*2326.2; %in Mpa
Fxc = Fxc*1200.1; %in Mpa
Fxy=.3524*(x)+.0884;Fxy=Fxy*1200.1; %in Mpa
end
채택된 답변
추가 답변 (1개)
%f
if Bita <= 0.1
....
....
elseif Bita > 0.1 & Bita <= 0.2
....
....
elseif Bita > 0.2 & Bita <= 0.3
....
....
end
% so on for other input values
Try this option
댓글 수: 3
%if true
Bita=round(abs(1-Alpha-x),1);
if Bita == 0.1000
....
....
elseif Bita == 0.2000
....
....
elseif Bita == 0.3000
....
....
end
% so on for other input values
The other option is round the value of Bita to single decimal units as shown at beginning
Dhananjay Hiwase
2021년 4월 30일
Dhananjay Hiwase
2021년 4월 30일
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!