How can i convert this flowchart to write matlab code? and how can i call an excel data (for prices example)to code
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
can someone help to write matlab code the attached flowchart ?
Risposte (2)
Jalaj Gambhir
il 24 Ago 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!
0 Commenti
Naven Raj
il 5 Giu 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 Commenti
Steven Lord
il 5 Giu 2021
Without knowing what errors you're receiving and what you entered at all those input statements it's going to be very difficult for us to help you determine why the code isn't behaving as you expect.
Instead, I recommend you use the debugging tools included in MATLAB to step through your code, line by line, as you follow along in your flowchart. Check as you execute each line that it moves you to the box in the flowchart you expect and when it doesn't, determine why not.
Vedere anche
Categorie
Scopri di più su Surrogate Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!