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

조회 수: 16 (최근 30일)
NN 2020년 8월 20일
댓글: Rik 2021년 6월 5일
can someone help to write matlab code the attached flowchart ?
Rik 2020년 8월 20일

댓글을 달려면 로그인하십시오.

답변 (2개)

Jalaj Gambhir 2020년 8월 24일
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이전 댓글 -2개 표시이전 댓글 -2개 숨기기

댓글을 달려면 로그인하십시오.

Naven Raj 2021년 6월 5일
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("\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'
end
fprintf("\n\n");
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
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
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("\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없음 표시없음 숨기기
Steven Lord 2021년 6월 5일
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.
Rik 2021년 6월 5일

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink 3D Animation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by