MATLAB Answers

How can i convert this flowchart to write matlab code? and how can i call an excel data (for prices example)to code

19 views (last 30 days)
NN
NN on 20 Aug 2020
Commented: Rik on 5 Jun 2021
can someone help to write matlab code the attached flowchart ?

Answers (2)

Jalaj Gambhir
Jalaj Gambhir on 24 Aug 2020
Hi,
I am assuming you want to know how to read data from excel files in your code. You can do so using readtable. You might find examples from this link useful.
Also, if you have any "specific" doubts in the implementation of the algorithm from the given flowchart, you can let us know
Hope this helps!

Naven Raj
Naven Raj on 5 Jun 2021
This is my flowchart.
I have tried doing the coding. I have mention the coding below. Its showing error most of the time. Can someone help myself to rectify the coding
% This program is to assign the Stability and Determinacy of Structure Beam
% and Truss
function main()
% Gethering input
Structure = input("Choose your structure '1-2': ",'s');
while Structure == '1'
r = input("Enter number of reaction: ");
n = input("Enter number of internal hinge: ");
X= n + 3;
if r < X
Beam = 'Statistical Unstable';
elseif r == X
Beam = 'Determinate';
elseif r > X
Beam = 'Indeterminate';
end
fprintf ("\n");
fprintf ("Your beam is %s",Beam);
fprintf("\n\n");
if Beam == "Indeterminate"
r= input("Enter number of reaction : ");
n= input("Enter number of internal hinge: ");
end
Degree=r-(n+3);
Degree=round(Degree,1);
fprintf("\n\n");
fprintf("Your degree of determinacy is %f\n",Degree);
fprintf("\n\n");
Selection=input("Would you like to continue?\n(please type Yes or No): ");
if Selection=="Yes"
main()
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
elseif Beam=='Determinate'
fprintf("Assign reaction calculator for \n1-Point load at the centre\n2-Point load at different distance\n3-Full Uniform distribution load\n");
Load= str (input("Choose your load position '1-3': "));
end
fprintf("\n\n");
while Load=='1'
fprintf("**********Assumed clockwise from the left point**********");
fprintf("\n\n");
F=input("Enter force value(kN):");
RB=F/2;
RB=round(RB,2);
RA=F-RB;
RA=round(RA,2);
fprintf("\n\n");
fprintf("Your RA is %.2fkN and RB is %.2fkN",RA,RB);
fprintf("\n\n");
Selection=input("Would you like to continue?\n(please type Yes or No): ",'s');
if Selection=="Yes"
main();
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
end
end
end
while Load=='2'
fprintf("**********Assumed clockwise from the left point**********");
fprintf("\n\n");
F=input("Enter force value(kN) :");
L=input("Enter length value(m) :");
x=input("Enter distance value near to the left point(m):");
RB=(F*x)/L;
RB=round(RB,2);
RA=F-RB;
RA=round(RA,2);
fprintf("\n\n");
fprintf("Your RA is %.2fkN and RB is %.2fkN",RA,RB);
fprintf("\n\n");
Selection=input("Would you like to continue?\n(please type Yes or No): ",'s');
if Selection=="Yes"
main()
else
if Selection=="No"
fprintf("Thank you and have a nice day")
return;
end
end
end
while Load=='3'
fprintf("**********Assumed clockwise from the left point**********")
fprintf("\n\n")
W=input("Enter force value(kN/m):");
L=input("Enter length value(m) :");
RB=(W*L)/2;
RB=round(RB,2);
RA=(W*L)-RB;
RA=round(RA,2);
fprintf("\n\n");
fprintf("Your RA is %.2fkN and RB is %.2fkN",RA,RB);
fprintf("\n\n");
Selection=input("Would you like to continue?\n(please type Yes or No): ",'s');
if Selection=="Yes"
main();
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
else
fprintf("Invalid option");
Selection=input("Would you like to continue?\n(please type Yes or No): ",'s');
fprintf("\n\n");
end
end
if Selection=="Yes"
main()
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
else
if Beam=="Statistical Unstable"
Selection=input("Would you like to continue?\n(please type Yes or No): ");
end
end
if Selection=="Yes"
main();
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
end
end
end
end
end
end
while Structure=='2'
m= input("Enter number of member : ");
j= input("Enter number of joint : ");
r= input("Enter number of reaction: ");
Y= 2*j - r;
if m < Y
Truss = 'Statistical Unstable';
elseif m == Y
Truss = 'Determinate' ;
elseif m > Y
Truss = 'Indeterminate';
end
fprintf ("\n\n");
fprintf ("Your Truss is %s",Truss);
fprintf("\n\n");
if Truss == "Indeterminate"
m= input("Enter number of member : ");
j= input("Enter number of joint : ");
r= input("Enter number of reaction: ");
end
Degree=m-(2*j - r);
Degree=round(Degree,1);
fprintf("\n\n");
fprintf("Your degree of determinacy is %.1f",Degree);
fprintf("\n\n");
Selection=input("Would you like to continue?\n(please type Yes or No): ",'s');
if Selection=="Yes"
main();
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
else
if Truss=="Statistical Unstable" || Truss=="Determinate"
Selection=input("Would you like to continue?\n(please type Yes or No): ",'s');
end
if Selection=="Yes"
main()
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
else
fprintf("Invalid option");
Selection=input("Would you like to continue?\n(please type Yes or No): ",'s');
fprintf("\n\n");
end
if Selection=="Yes"
main();
else
if Selection=="No"
fprintf("Thank you and have a nice day");
return;
end
end
end
end
end
end
end
  2 Comments
Rik
Rik on 5 Jun 2021
Have a read here and here. It will greatly improve your chances of getting an answer.
This is not an answer, but a question. Please follow the advice from Steven and from these links, and delete this answer.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by