Problem with if and else and else

1 Ansicht (letzte 30 Tage)
joshua Abam
joshua Abam am 13 Jan. 2020
Kommentiert: joshua Abam am 14 Jan. 2020
Dear all,
I have a problem which i despiratly need an help with.
The idea I am think of is a suituation were if the first if statment is ok trhen the porgram stop however if the condition is not met, it moves to the next which i represent here with elseif and so on till the last elseif ststment.
Please I will appreaciate all contribution
if (0.04<=t_1/Do<0.05) % If condition
t_1 = Pd*di/(2*k*Fy) % Determine the minimum thickness
Do = di + 2*t_1 % Define the external diameter
elseif (0.04<=t_2/D1<0.05) % Elseif condition for the second round
t_2 = (Pd-Pe)*D1/2*k*Fy %Determine the minimum thickness
D1 = di + 2*t_2 %Define the external Diameter
elseif (0.04<=t_3/D2<0.05) %elseif condition for the final round
t_3 = D2/(((4*Fy)/(Y_sc*Ym*(Pd-Pe)*sqrt(3))) + 1) %Determine the minimum thickness
D2 = di + 2*t_3 %Define the external Diameter
end

Akzeptierte Antwort

David Hill
David Hill am 13 Jan. 2020
if 0.04<=t_1/Do&&t_1/Do<0.05 %need &&
t_1 = Pd*di/(2*k*Fy);
Do = di + 2*t_1;
elseif 0.04<=t_2/D1&&t_2/D1<0.05
t_2 = (Pd-Pe)*D1/2*k*Fy;
D1 = di + 2*t_2;
elseif 0.04<=t_3/D2&&t_3/D2<0.05
t_3 = D2/(((4*Fy)/(Y_sc*Ym*(Pd-Pe)*sqrt(3))) + 1);
D2 = di + 2*t_3;
end
  1 Kommentar
joshua Abam
joshua Abam am 14 Jan. 2020
Hi David,
sorry can you help by point me to the right direct as if statement is not giving the right answer
it borders on the same challenge
Thanks
to = Pli*di/(2*k*Fy) % Determine the minimum thickness
Do = di + 2*t_1 % Define the external diameter
0.04<=to/Do&&to/Do<0.05 % If condition
% if logical true disp(Do) and disp(to) ortherwise continue
t_2 = (Pli-Pe)*Do/2*k*Fy % Determine the minimum thickness
D_2 = di + 2*t_2 % Define the external Diameter
0.04<=t_2/D_2&&t_2/D_2<0.05 % Elseif condition for the second round
% if logical true disp(D_2) and disp(t_2) ortherwise continue
t_3 = Do/(((4*Fy)/(Y_sc*Ym*(Pli-Pe)*sqrt(3))) + 1) % Determine the minimum thickness
D_3 = di + 2*t_3 % Define the external Diameter
0.04<=t_3/D_3&&t_3/D_3<0.05 % elseif condition for the final round
% if logical true disp(D_3) and disp(t_3) ortherwise display not true
%and if logical true it should use in the next equation
%let say
x = D; %Let say D is the outcome from the logical statment
%That is now substituted into the equation below to below
% Bursting Criteria from Numerical Analysis of DNV-OS-F201
(Pli-Pe)*Y_sc*Ym - 4*f_min*(0.5*(x)-0.127)/(sqrt(3)*(x)-(0.5*(x)-0.127))<=0

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by