matlab coding how to do this?

4 visualizzazioni (ultimi 30 giorni)
Lanya Patel
Lanya Patel il 24 Nov 2021
Commentato: Rena Berman il 13 Dic 2021
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 Commenti
Rik
Rik il 25 Nov 2021
Modificato: Rik il 25 Nov 2021
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
Rena Berman il 13 Dic 2021

(Answers Dev) Restored edit

Accedi per commentare.

Risposte (2)

Rik
Rik il 24 Nov 2021
doc input
doc if

Image Analyst
Image Analyst il 24 Nov 2021
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 Commenti
Lanya Patel
Lanya Patel il 24 Nov 2021
still struggling tbh @Image Analyst
Image Analyst
Image Analyst il 24 Nov 2021
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.

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by