필터 지우기
필터 지우기

A small problem on my homework assignment has something to do with case expression.

조회 수: 4 (최근 30일)
Here is the full question
Suppose that a student has the option of enrolling for a single elective during a term. The student must select a course from a limited list of options: “English,” “History,” “Biology,” “Computer,” or “Math.” Construct a fragment of MATLAB code that will prompt the student for his or her choice, read in the choice, and use the answer as the case expression for a switch construct. Be sure to include a default case to handle invalid inputs. Testing three cases: (a) Computer (b) Physics (c) Biology.
Now the problem is the first part i dont understand the "Construct a fragment of MATLAB code that will prompt the student for his or her choice, read in the choice," part. I know how to do the case expression part.
I dont want you guys to do the problem for me just guide me. Plz Love you all <3

채택된 답변

Image Analyst
Image Analyst 2014년 10월 30일
Did you happen to find menu() in the help? Try this:
button = menu('Select a class', '(a) Computer', ' (b) Physics', '(c) Biology');
switch button
.... more code.....
  댓글 수: 4
Hasan
Hasan 2014년 10월 30일
Thanks, im new the matlab so im a newb. Thanks for the help and ill let you know if it works xD. is it okay if i show you the code so that you can confirm it?

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

추가 답변 (1개)

Ken Atwell
Ken Atwell 2014년 10월 30일
I like Image Analyst's suggestion because a multiple-choice UI eliminate the need to check for bad input, but your professor might be looking for the input function, used to gather textual input in the Command Window.
Have fun.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by