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?
조회 수: 9 (최근 30일)
이전 댓글 표시
input('input any fraction?');
fraction = 1/ 2;
if (fraction == 1)&& (1>2)
disp('proper fraction.');
elseif (fraction == 1) && (1>=2 )
disp('whole number');
else
fprintf('improper fraction');
end
댓글 수: 1
답변 (1개)
Cris LaPierre
2021년 9월 20일
편집: Cris LaPierre
2021년 9월 20일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!