what function should I use in order for the matlab to evaluate the entered number if it is proper fraction, improper fraction, or Whole number?

10 vues (au cours des 30 derniers jours)
input('input any fraction?');
Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering.
fraction = 1/ 2;
if (fraction == 1)&& (1>2)
disp('proper fraction.');
elseif (fraction == 1) && (1>=2 )
disp('whole number');
else
fprintf('improper fraction');
end

Réponses (1)

Cris LaPierre
Cris LaPierre le 20 Sep 2021
Modifié(e) : Cris LaPierre le 20 Sep 2021
You appear to be using MATLAB Grader, which does not support user interactions like input. You will need to find a different way of obtaining the fraction. This is likely a function-type problem, so you need to write a function. The fraction is likely supposed to be an input to the function.
Learn more about creating MATLAB functions here: https://www.mathworks.com/help/matlab/ref/function.html

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by