필터 지우기
필터 지우기

Problem with script use

조회 수: 1 (최근 30일)
David
David 2020년 4월 21일
답변: Sriram Tadavarty 2020년 4월 21일
Hi,
I got a problem of using a script. Normally, when I can create a function in a script, I can apply the function in the command window. But I am now assigned a homework that asking me to do a live script. It means that I have to create some options on the script and the user will input one of those options
For example :
Option 1 : blue
Option 2 : red
Option 3 : yellow
Enter your choice:
Notice that If i enter my choice which is 1 (blue). It will return blue color.
I know how to input matlab code imread and imshow to show the picture of blue color but will I use if function at the end of the script or on each line after the option??
How can I create a script like that? I don't know how to explain it correctly since I am a English beginner. If you want further information to understand my idea, please tell me.
Here is my trial and I was confused how can I enter my choice when a run a script.? Please give me some references to understand how to run this code.
display('Hello User!!')
display('Option 1: Flip the picture !!')
display('Option 2: Get back to 1900s by grayscaling !!')
display('Option 3: Complementing the picture !!')
display('Option 4: Rotating the image to 90 degree')
display('Option 5: Rotating the image to 90 degree')
display('Enter a valid choice: ')
  댓글 수: 5
David
David 2020년 4월 21일
hi, thanks for your response. I got it. This would be much easier for me. Thanks you very much.
Sriram Tadavarty
Sriram Tadavarty 2020년 4월 21일
Glad that it helped. I will place the same in answer

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

채택된 답변

Sriram Tadavarty
Sriram Tadavarty 2020년 4월 21일
Hi David,
To enter a choice when run a script, you can use input function.
Try
n = input('Enter a valid choice: ');
% Then perform the different operations based on the value of n, through switch or if-else statements
For more details, look at the input documentation page.
Hope this helps.
Regards,
Sriram

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by