Use flowchart for Matlab

I am trying to write a script named as tstdigit.m using this flow chart
so far all I have is:
>> a = input('please enter a: ');
please enter a: if a > 0
if a > 0

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 11월 7일
편집: KALYAN ACHARJYA 2018년 11월 7일

0 개 추천

% Try to learn, as you have shared, what you have done, that's why I have posted the answer.
% try to learn, learn by doing
a=input('Input a: Enter the number ');
if a<0
disp('Nagative Value');
else
if a<10
disp('Single Digit');
else
disp('Out of range');
end
end

댓글 수: 8

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 11월 7일
편집: KALYAN ACHARJYA 2018년 11월 7일
Above code is according to the flow of the diagram, another way you can implement the same logic with single if else statement
a=input('Input a: Enter the number ');
if a<0
disp('Nagative Value');
elseif a<10
disp('Single Digit');
else
disp('Out of range');
end
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 11월 7일
편집: KALYAN ACHARJYA 2018년 11월 7일
And for a=10, the logic is not provided in the flowchart.
SP
SP 2018년 11월 7일
when I use this, the output values I get are not correct, I get the same answer
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 11월 7일
no, show me the results
Shamsher Ansari
Shamsher Ansari 2020년 4월 21일
Kalyan sir, Thank you
but how I can Become like you a Matlab Programmer
please suggest me
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 4월 21일
편집: KALYAN ACHARJYA 2020년 4월 21일
Oh, I am also learner here, Just practice..repeat ..practice
See the answers provided by members and start here
Good Wishes!
Shamsher Ansari
Shamsher Ansari 2020년 4월 21일
편집: Shamsher Ansari 2020년 4월 21일
Thank you sir,
Please sir, reply to my question on the above problem with small modification" .....what change will be in the program,,,,please sir...........(at "input a" suppose there is some calculation and i want to repeat it to some extent to achieve a perticular result)
while condition
% Previous code
end
Till the condition not met it iterative continlusly, please ensure that once condition must be met, otherwise it will run infinitely.

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

Aatif Ameer
Aatif Ameer 2020년 12월 26일

0 개 추천

Can anyone solve the problem, i am attaching it with the ques. please convert flow chat into matlab code.

카테고리

도움말 센터File Exchange에서 Aerospace Applications에 대해 자세히 알아보기

태그

질문:

SP
2018년 11월 7일

댓글:

2020년 12월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by