필터 지우기
필터 지우기

Can I have Matlab read and check my user input form the keyboard and then write that input to a file?

조회 수: 1 (최근 30일)
Hey guys,
I am working on a project that I want to get the input from the user but I can never have matlab check for the specific input the go to the next step.
I tried sscanf but that didnt work. My idea is to prompt the user "please press Y or N". check for input (sscanf) then if YES do this then write it to a file (fprintf(fid,format,A)) and if NO do something else and write to that file also...
I also tried using that concept but didnt work:
reply = input('Do you want more? Y/N [Y]: ', 's');
if isempty(reply)
reply = 'Y';
end
Can you help?

답변 (1개)

Walter Roberson
Walter Roberson 2013년 2월 25일
if strcmpi(reply, 'Y')
Note: sscanf() can only be applied to a string. fscanf() can be applied to a file, but fscanf() cannot be applied to user input from the keyboard -- only input() can be used for that.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by