how do i write commands for errors and warnings in Matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Q# Display an error message ‘Negative value(s), not acceptable.’ as long as one of the entered values is non-negative. (For this question i got the code below but i don't know if it is correct or not)
- function [BMI] = BMI (weight, height)
- BMI = (weight / (height^2));
- if ~isnumeric (weight) || ~isnumeric(height)
- error('Negative value(s), not acceptable.');
- end
Q# Display a warning message ‘Caution, value(s) may be invalid.’ to alert the user as long as one of the entered values is not reasonable, e.g. height > 2.5 or < 1.5 m; or weight < 30 or > 200 kg. (Can someone please help me writing code for this statement)
0 comentarios
Respuestas (1)
John D'Errico
el 18 de Mzo. de 2022
Editada: John D'Errico
el 18 de Mzo. de 2022
You wrote code for an ERROR message. If you don't know if it is correct, then TRY IT! Does it do as requested?
An error terminates execution, and that was not what you are supposed to do in the second question. So you need to do somethign different.
Instead, what does the function WARNING do? Read the help.
0 comentarios
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!