Problem with input command

조회 수: 19 (최근 30일)
William Bober
William Bober 2016년 5월 31일
답변: Image Analyst 2016년 5월 31일
I teach MATLAB at Florida Atlantic University. In one of my examples I have the following 2 lines:
fprintf('Enter the temperature at which the properties \n');
T=input('are to be determined \n');
In all previous versions the computer would pause and the cursor would go to the Command Window waiting for the user to enter a value. In MATLAB version R2016A, the cursor remains in the script, so if I start typing a response it prints it to the script and not to the Command Window. I need to click in the Command Window to enter a response to the input command. This was not the case with previous versions of MATLAB.
  댓글 수: 3
William Bober
William Bober 2016년 5월 31일
Clicking on the run icon.
Image Analyst
Image Analyst 2016년 5월 31일
For me too (in R2016a), the active window is the script, and not the command window. When you just start typing immediately, it shows up in the script editor window, not the command window. I don't know why.

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

채택된 답변

Image Analyst
Image Analyst 2016년 5월 31일
Seems like a bug to me. You can get around it by using inputdlg:
userPrompt = sprintf('Enter the temperature at which the properties\nare to be determined');
T=inputdlg('Enter temperature', userPrompt);
T % Echo to command window.

추가 답변 (1개)

Ahmed Rashid
Ahmed Rashid 2016년 5월 31일
Hello, It works as intended here. I run it on a Windows machine (Windows 10). You can maybe try it on another computer.
It might be like that for your OS only.
  댓글 수: 1
William Bober
William Bober 2016년 5월 31일
On previous versions of MATLAB, running the input command always resulted on the cursor going to the Command Window. It doesn't work that way on my system now

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

카테고리

Help CenterFile Exchange에서 Install Products에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by