matlab coding how to do this?

4 visualizaciones (últimos 30 días)
Lanya Patel
Lanya Patel el 24 de Nov. de 2021
Comentada: Rena Berman el 13 de Dic. de 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 comentarios
Rik
Rik el 25 de Nov. de 2021
Editada: Rik el 25 de Nov. de 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 el 13 de Dic. de 2021

(Answers Dev) Restored edit

Iniciar sesión para comentar.

Respuestas (2)

Rik
Rik el 24 de Nov. de 2021
doc input
doc if

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

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by