How to avoid too many if else statements
up vote
0
down vote
favorite
I am writing a simple app using matlab app designer, My code works but I want to make it better. I have too many if else conditions. How can I avoid this? I use matlab app designer, I take 3 values and compare them again and again with different sets
function buttonpush3Act(app, event)
a3= app.StrokeLengthmmEditField_13.Value;
b3=app.StrokeLengthmmEditField_12.Value;
c3= app.StrokeLengthmmEditField_11.Value;
d3=app.BuildingDimensionmmEditField_6.Value;
e3=app.BuildingDimensionmmEditField_5.Value;
f3=app.BuildingDimensionmmEditField_4.Value;
g3=app.orPreconfiguredrefnumEditField.Value;
h3=app.orPreconfiguredrefnumEditField_2.Value;
i3=app.orPreconfiguredrefnumEditField_3.Value;
j3=app.ActuatorTypeNumberEditField.Value;
k3=app.ActuatorTypeNumberEditField_2.Value;
l3=app.ActuatorTypeNumberEditField_3.Value;
%reset message field
app.OutputMessageEditField_2.Value= "";
% avoid missuse of the ´result´button
if(a3==0 && b3==0 && c3==0 && d3==0 && e3==0 && f3==0 && g3==0 && h3==0)
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value ='';
%check for pre configured actuators
elseif((j3== k3 == l3 || j3== k3 || j3== l3 || k3 == l3) && (j3 > 0 && k3 > 0 && l3 > 0)) %avoid having more than one LA40
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value =" ERROR2: Unsupported configuration";
%check if special actuators present
elseif((j3 == 40 && k3 ~= 40 && l3 ~= 40) || (j3 ~= 40 && k3 == 40 && l3 ~= 40) || (j3 ~= 40 && k3 ~= 40 && l3 == 40))
% a rotation to to catch la 40 and define it as ref4
dataLa40 = [j3,k3,l3];
ref4 = dataLa40(1)
for r= 1:length(dataLa40)
if dataLa40(r) == 40;
ref4 = dataLa40(r);
end
end
if (ref4 == dataLa40(1))
app.Actuator1EditField.Value = "ref4";
elseif(ref4 == dataLa40(2) )
app.Actuator2EditField.Value = "ref4";
else(ref4 == dataLa40(3))
app.Actuator3EditField.Value = "ref4";
end
% if act1== ref4 what if act2== ref4 what if act3== ref4 what
%check for rule D
elseif((a3 ~= b3) && (a3~= c3) && (b3 ~= c3) && (a3 > 0 && b3 > 0 && c3 > 0))
data= [a3,b3,c3];
ref2= data(1)
ref3=data(1)
ref1=data(1)
for j = 1:length(data)
%largest stroke length
if data(j)>ref2;
ref2=data(j);
end
end
for k = 1:length(data)
%smallest stroke length
if data(k)<ref3;
ref3=data(k);
end
end
for m = 1:length(data)
%stroke length in the middle
if ref3<data(m) & data(m)<ref2;
ref1=data(m);
end
end
if (ref2== a3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==b3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==c3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==a3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==b3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==c3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==a3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==b3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==c3)
app.Actuator3EditField.Value= "ref1" ;
end
% elseif((a3 == b3) || (a3 == c3) || (b3 == c3))
%check for rule C
else(((a3 == b3) || (a3 == c3) || (b3 == c3)) && (a3 > 0 && b3 > 0 && c3 > 0))
data_list= [d3,e3,f3];
ref2= data_list(1)
ref3=data_list(1)
ref1=data_list(1)
for n = 1:length(data_list)
%largest Building Dimension
if data_list(n)>ref2;
ref2=data_list(n);
end
end
for p = 1:length(data_list)
%smallest Building Dimension
if data_list(p)<ref3;
ref3=data_list(p);
end
end
for q = 1:length(data_list)
%Building Dimension in the middle
if ref3<data_list(q) & data_list(q)<ref2;
ref1=data_list(q);
end
end
if (ref2== d3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==e3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==f3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==d3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==e3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==f3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==d3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==e3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==f3)
app.Actuator3EditField.Value= "ref1" ;
end
%check for eqaul building dimentions
if(((d3 == e3) || (d3 == f3) || (e3 == f3)) && (d3 > 0 && e3 > 0 && f3 > 0))
app.OutputMessageEditField_2.Value ="Use channel assignment or config. tool";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
else
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
%should be out of main loop, independent
if(a3 == 0 ||b3 == 0 ||c3 == 0 ||d3 == 0 ||e3 == 0 ||f3 == 0 ||j3 == 0 ||k3 == 0 ||l3 == 0 )
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
matlab
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
I am writing a simple app using matlab app designer, My code works but I want to make it better. I have too many if else conditions. How can I avoid this? I use matlab app designer, I take 3 values and compare them again and again with different sets
function buttonpush3Act(app, event)
a3= app.StrokeLengthmmEditField_13.Value;
b3=app.StrokeLengthmmEditField_12.Value;
c3= app.StrokeLengthmmEditField_11.Value;
d3=app.BuildingDimensionmmEditField_6.Value;
e3=app.BuildingDimensionmmEditField_5.Value;
f3=app.BuildingDimensionmmEditField_4.Value;
g3=app.orPreconfiguredrefnumEditField.Value;
h3=app.orPreconfiguredrefnumEditField_2.Value;
i3=app.orPreconfiguredrefnumEditField_3.Value;
j3=app.ActuatorTypeNumberEditField.Value;
k3=app.ActuatorTypeNumberEditField_2.Value;
l3=app.ActuatorTypeNumberEditField_3.Value;
%reset message field
app.OutputMessageEditField_2.Value= "";
% avoid missuse of the ´result´button
if(a3==0 && b3==0 && c3==0 && d3==0 && e3==0 && f3==0 && g3==0 && h3==0)
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value ='';
%check for pre configured actuators
elseif((j3== k3 == l3 || j3== k3 || j3== l3 || k3 == l3) && (j3 > 0 && k3 > 0 && l3 > 0)) %avoid having more than one LA40
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value =" ERROR2: Unsupported configuration";
%check if special actuators present
elseif((j3 == 40 && k3 ~= 40 && l3 ~= 40) || (j3 ~= 40 && k3 == 40 && l3 ~= 40) || (j3 ~= 40 && k3 ~= 40 && l3 == 40))
% a rotation to to catch la 40 and define it as ref4
dataLa40 = [j3,k3,l3];
ref4 = dataLa40(1)
for r= 1:length(dataLa40)
if dataLa40(r) == 40;
ref4 = dataLa40(r);
end
end
if (ref4 == dataLa40(1))
app.Actuator1EditField.Value = "ref4";
elseif(ref4 == dataLa40(2) )
app.Actuator2EditField.Value = "ref4";
else(ref4 == dataLa40(3))
app.Actuator3EditField.Value = "ref4";
end
% if act1== ref4 what if act2== ref4 what if act3== ref4 what
%check for rule D
elseif((a3 ~= b3) && (a3~= c3) && (b3 ~= c3) && (a3 > 0 && b3 > 0 && c3 > 0))
data= [a3,b3,c3];
ref2= data(1)
ref3=data(1)
ref1=data(1)
for j = 1:length(data)
%largest stroke length
if data(j)>ref2;
ref2=data(j);
end
end
for k = 1:length(data)
%smallest stroke length
if data(k)<ref3;
ref3=data(k);
end
end
for m = 1:length(data)
%stroke length in the middle
if ref3<data(m) & data(m)<ref2;
ref1=data(m);
end
end
if (ref2== a3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==b3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==c3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==a3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==b3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==c3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==a3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==b3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==c3)
app.Actuator3EditField.Value= "ref1" ;
end
% elseif((a3 == b3) || (a3 == c3) || (b3 == c3))
%check for rule C
else(((a3 == b3) || (a3 == c3) || (b3 == c3)) && (a3 > 0 && b3 > 0 && c3 > 0))
data_list= [d3,e3,f3];
ref2= data_list(1)
ref3=data_list(1)
ref1=data_list(1)
for n = 1:length(data_list)
%largest Building Dimension
if data_list(n)>ref2;
ref2=data_list(n);
end
end
for p = 1:length(data_list)
%smallest Building Dimension
if data_list(p)<ref3;
ref3=data_list(p);
end
end
for q = 1:length(data_list)
%Building Dimension in the middle
if ref3<data_list(q) & data_list(q)<ref2;
ref1=data_list(q);
end
end
if (ref2== d3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==e3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==f3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==d3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==e3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==f3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==d3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==e3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==f3)
app.Actuator3EditField.Value= "ref1" ;
end
%check for eqaul building dimentions
if(((d3 == e3) || (d3 == f3) || (e3 == f3)) && (d3 > 0 && e3 > 0 && f3 > 0))
app.OutputMessageEditField_2.Value ="Use channel assignment or config. tool";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
else
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
%should be out of main loop, independent
if(a3 == 0 ||b3 == 0 ||c3 == 0 ||d3 == 0 ||e3 == 0 ||f3 == 0 ||j3 == 0 ||k3 == 0 ||l3 == 0 )
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
matlab
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome to Code Review! This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. The current title states your concerns about the code; it needs an edit to simply state the task; see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
2 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am writing a simple app using matlab app designer, My code works but I want to make it better. I have too many if else conditions. How can I avoid this? I use matlab app designer, I take 3 values and compare them again and again with different sets
function buttonpush3Act(app, event)
a3= app.StrokeLengthmmEditField_13.Value;
b3=app.StrokeLengthmmEditField_12.Value;
c3= app.StrokeLengthmmEditField_11.Value;
d3=app.BuildingDimensionmmEditField_6.Value;
e3=app.BuildingDimensionmmEditField_5.Value;
f3=app.BuildingDimensionmmEditField_4.Value;
g3=app.orPreconfiguredrefnumEditField.Value;
h3=app.orPreconfiguredrefnumEditField_2.Value;
i3=app.orPreconfiguredrefnumEditField_3.Value;
j3=app.ActuatorTypeNumberEditField.Value;
k3=app.ActuatorTypeNumberEditField_2.Value;
l3=app.ActuatorTypeNumberEditField_3.Value;
%reset message field
app.OutputMessageEditField_2.Value= "";
% avoid missuse of the ´result´button
if(a3==0 && b3==0 && c3==0 && d3==0 && e3==0 && f3==0 && g3==0 && h3==0)
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value ='';
%check for pre configured actuators
elseif((j3== k3 == l3 || j3== k3 || j3== l3 || k3 == l3) && (j3 > 0 && k3 > 0 && l3 > 0)) %avoid having more than one LA40
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value =" ERROR2: Unsupported configuration";
%check if special actuators present
elseif((j3 == 40 && k3 ~= 40 && l3 ~= 40) || (j3 ~= 40 && k3 == 40 && l3 ~= 40) || (j3 ~= 40 && k3 ~= 40 && l3 == 40))
% a rotation to to catch la 40 and define it as ref4
dataLa40 = [j3,k3,l3];
ref4 = dataLa40(1)
for r= 1:length(dataLa40)
if dataLa40(r) == 40;
ref4 = dataLa40(r);
end
end
if (ref4 == dataLa40(1))
app.Actuator1EditField.Value = "ref4";
elseif(ref4 == dataLa40(2) )
app.Actuator2EditField.Value = "ref4";
else(ref4 == dataLa40(3))
app.Actuator3EditField.Value = "ref4";
end
% if act1== ref4 what if act2== ref4 what if act3== ref4 what
%check for rule D
elseif((a3 ~= b3) && (a3~= c3) && (b3 ~= c3) && (a3 > 0 && b3 > 0 && c3 > 0))
data= [a3,b3,c3];
ref2= data(1)
ref3=data(1)
ref1=data(1)
for j = 1:length(data)
%largest stroke length
if data(j)>ref2;
ref2=data(j);
end
end
for k = 1:length(data)
%smallest stroke length
if data(k)<ref3;
ref3=data(k);
end
end
for m = 1:length(data)
%stroke length in the middle
if ref3<data(m) & data(m)<ref2;
ref1=data(m);
end
end
if (ref2== a3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==b3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==c3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==a3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==b3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==c3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==a3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==b3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==c3)
app.Actuator3EditField.Value= "ref1" ;
end
% elseif((a3 == b3) || (a3 == c3) || (b3 == c3))
%check for rule C
else(((a3 == b3) || (a3 == c3) || (b3 == c3)) && (a3 > 0 && b3 > 0 && c3 > 0))
data_list= [d3,e3,f3];
ref2= data_list(1)
ref3=data_list(1)
ref1=data_list(1)
for n = 1:length(data_list)
%largest Building Dimension
if data_list(n)>ref2;
ref2=data_list(n);
end
end
for p = 1:length(data_list)
%smallest Building Dimension
if data_list(p)<ref3;
ref3=data_list(p);
end
end
for q = 1:length(data_list)
%Building Dimension in the middle
if ref3<data_list(q) & data_list(q)<ref2;
ref1=data_list(q);
end
end
if (ref2== d3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==e3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==f3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==d3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==e3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==f3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==d3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==e3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==f3)
app.Actuator3EditField.Value= "ref1" ;
end
%check for eqaul building dimentions
if(((d3 == e3) || (d3 == f3) || (e3 == f3)) && (d3 > 0 && e3 > 0 && f3 > 0))
app.OutputMessageEditField_2.Value ="Use channel assignment or config. tool";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
else
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
%should be out of main loop, independent
if(a3 == 0 ||b3 == 0 ||c3 == 0 ||d3 == 0 ||e3 == 0 ||f3 == 0 ||j3 == 0 ||k3 == 0 ||l3 == 0 )
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
matlab
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I am writing a simple app using matlab app designer, My code works but I want to make it better. I have too many if else conditions. How can I avoid this? I use matlab app designer, I take 3 values and compare them again and again with different sets
function buttonpush3Act(app, event)
a3= app.StrokeLengthmmEditField_13.Value;
b3=app.StrokeLengthmmEditField_12.Value;
c3= app.StrokeLengthmmEditField_11.Value;
d3=app.BuildingDimensionmmEditField_6.Value;
e3=app.BuildingDimensionmmEditField_5.Value;
f3=app.BuildingDimensionmmEditField_4.Value;
g3=app.orPreconfiguredrefnumEditField.Value;
h3=app.orPreconfiguredrefnumEditField_2.Value;
i3=app.orPreconfiguredrefnumEditField_3.Value;
j3=app.ActuatorTypeNumberEditField.Value;
k3=app.ActuatorTypeNumberEditField_2.Value;
l3=app.ActuatorTypeNumberEditField_3.Value;
%reset message field
app.OutputMessageEditField_2.Value= "";
% avoid missuse of the ´result´button
if(a3==0 && b3==0 && c3==0 && d3==0 && e3==0 && f3==0 && g3==0 && h3==0)
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value ='';
%check for pre configured actuators
elseif((j3== k3 == l3 || j3== k3 || j3== l3 || k3 == l3) && (j3 > 0 && k3 > 0 && l3 > 0)) %avoid having more than one LA40
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
app.OutputMessageEditField_2.Value =" ERROR2: Unsupported configuration";
%check if special actuators present
elseif((j3 == 40 && k3 ~= 40 && l3 ~= 40) || (j3 ~= 40 && k3 == 40 && l3 ~= 40) || (j3 ~= 40 && k3 ~= 40 && l3 == 40))
% a rotation to to catch la 40 and define it as ref4
dataLa40 = [j3,k3,l3];
ref4 = dataLa40(1)
for r= 1:length(dataLa40)
if dataLa40(r) == 40;
ref4 = dataLa40(r);
end
end
if (ref4 == dataLa40(1))
app.Actuator1EditField.Value = "ref4";
elseif(ref4 == dataLa40(2) )
app.Actuator2EditField.Value = "ref4";
else(ref4 == dataLa40(3))
app.Actuator3EditField.Value = "ref4";
end
% if act1== ref4 what if act2== ref4 what if act3== ref4 what
%check for rule D
elseif((a3 ~= b3) && (a3~= c3) && (b3 ~= c3) && (a3 > 0 && b3 > 0 && c3 > 0))
data= [a3,b3,c3];
ref2= data(1)
ref3=data(1)
ref1=data(1)
for j = 1:length(data)
%largest stroke length
if data(j)>ref2;
ref2=data(j);
end
end
for k = 1:length(data)
%smallest stroke length
if data(k)<ref3;
ref3=data(k);
end
end
for m = 1:length(data)
%stroke length in the middle
if ref3<data(m) & data(m)<ref2;
ref1=data(m);
end
end
if (ref2== a3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==b3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==c3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==a3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==b3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==c3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==a3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==b3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==c3)
app.Actuator3EditField.Value= "ref1" ;
end
% elseif((a3 == b3) || (a3 == c3) || (b3 == c3))
%check for rule C
else(((a3 == b3) || (a3 == c3) || (b3 == c3)) && (a3 > 0 && b3 > 0 && c3 > 0))
data_list= [d3,e3,f3];
ref2= data_list(1)
ref3=data_list(1)
ref1=data_list(1)
for n = 1:length(data_list)
%largest Building Dimension
if data_list(n)>ref2;
ref2=data_list(n);
end
end
for p = 1:length(data_list)
%smallest Building Dimension
if data_list(p)<ref3;
ref3=data_list(p);
end
end
for q = 1:length(data_list)
%Building Dimension in the middle
if ref3<data_list(q) & data_list(q)<ref2;
ref1=data_list(q);
end
end
if (ref2== d3)
app.Actuator1EditField.Value= "ref2" ;
elseif(ref2==e3)
app.Actuator2EditField.Value= "ref2" ;
else(ref2==f3)
app.Actuator3EditField.Value= "ref2" ;
end
if(ref3==d3)
app.Actuator1EditField.Value= "ref3" ;
elseif(ref3==e3)
app.Actuator2EditField.Value= "ref3" ;
else(ref3==f3)
app.Actuator3EditField.Value= "ref3" ;
end
if(ref1==d3)
app.Actuator1EditField.Value= "ref1" ;
elseif(ref1==e3)
app.Actuator2EditField.Value= "ref1" ;
else(ref1==f3)
app.Actuator3EditField.Value= "ref1" ;
end
%check for eqaul building dimentions
if(((d3 == e3) || (d3 == f3) || (e3 == f3)) && (d3 > 0 && e3 > 0 && f3 > 0))
app.OutputMessageEditField_2.Value ="Use channel assignment or config. tool";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
else
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
%should be out of main loop, independent
if(a3 == 0 ||b3 == 0 ||c3 == 0 ||d3 == 0 ||e3 == 0 ||f3 == 0 ||j3 == 0 ||k3 == 0 ||l3 == 0 )
app.OutputMessageEditField_2.Value ="ERROR2; Fill the required fields";
app.Actuator1EditField.Value= '';
app.Actuator2EditField.Value= '';
app.Actuator3EditField.Value ='';
end
end
matlab
matlab
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 46 mins ago
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 hours ago
Gombakka
11
11
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Gombakka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome to Code Review! This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. The current title states your concerns about the code; it needs an edit to simply state the task; see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
2 hours ago
add a comment |
Welcome to Code Review! This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. The current title states your concerns about the code; it needs an edit to simply state the task; see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
2 hours ago
Welcome to Code Review! This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. The current title states your concerns about the code; it needs an edit to simply state the task; see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
2 hours ago
Welcome to Code Review! This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. The current title states your concerns about the code; it needs an edit to simply state the task; see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
2 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Gombakka is a new contributor. Be nice, and check out our Code of Conduct.
Gombakka is a new contributor. Be nice, and check out our Code of Conduct.
Gombakka is a new contributor. Be nice, and check out our Code of Conduct.
Gombakka is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207537%2fhow-to-avoid-too-many-if-else-statements%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Welcome to Code Review! This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. The current title states your concerns about the code; it needs an edit to simply state the task; see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
2 hours ago