matlab coding how to do this?
이전 댓글 표시
Task 3: Another simple script file Write a Matlab script file to do the following:
Accept a number from the user.
If the number entered is less than 100 then displays the message “Number is less than 100”, and print the number entered.
If the number entered lies between [100, 200] inclusive then displays the message “Number lies between 100 and 200”, and print the number entered. •
If the number entered is greater than 200 then displays the message “Number greater than 200”, and print the number entered. A possible Matlab session calling the script file may looks like the following:
댓글 수: 2
Why did you edit away your question? Were you afraid your teacher would find this question and consider this cheating?
Anyway, here is the original question:
matlab coding how to do this?
Task 3: Another simple script file Write a Matlab script file to do the following:
Accept a number from the user.
If the number entered is less than 100 then displays the message “Number is less than 100”, and print the number entered.
If the number entered lies between [100, 200] inclusive then displays the message “Number lies between 100 and 200”, and print the number entered. •
If the number entered is greater than 200 then displays the message “Number greater than 200”, and print the number entered. A possible Matlab session calling the script file may looks like the following:
Rena Berman
2021년 12월 13일
(Answers Dev) Restored edit
답변 (2개)
Rik
2021년 11월 24일
doc input
doc if
Image Analyst
2021년 11월 24일
Hint:
% Ask user for two floating point numbers.
defaultValue = {'400'};
titleBar = 'Enter values';
userPrompt = {'Enter floating point number 1 : '};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValue);
if isempty(caUserInput),return,end % Bail out if they clicked Cancel.
% Convert to floating point from string.
usersValue1 = str2double(caUserInput{1})
% Check usersValue1 for validity.
if isnan(usersValue1)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
% Convert the default from a string and stick that into usersValue1.
usersValue1 = str2double(defaultValue{1});
message = sprintf('I said it had to be a number.\nTry replacing the user.\nI will use %.2f and continue.', usersValue1);
uiwait(warndlg(message));
end
if usersValue1 < 100
% code
elseif usersValue1 < 200
% code
end
etc.
댓글 수: 3
Lanya Patel
2021년 11월 24일
Lanya Patel
2021년 11월 24일
Image Analyst
2021년 11월 24일
How much of your homework are we allowed to do? All of it? I'm afraid if I do more then you'd get in trouble for copying someone elses code and turning it in as your own.
Actually you just deleted your question and I don't remember what it was anymore.
카테고리
도움말 센터 및 File Exchange에서 Scripts에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!