Setting a range of values
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Erkan Karaoglu
el 25 de Jun. de 2021
Comentada: Erkan Karaoglu
el 25 de Jun. de 2021
Hello to everyone. I want to enter a number and see the result. An "x" number and a "y" will be entered. For example; If 0<x<58 and Y>120 then ''1. Panel faulty'' If 0<x<58 and Y<120, ''16. The result "Panel faulty" will be obtained. If the entered number is not within this range, 58<x<118 and Y>118 is ''2. Panel is faulty'', 58<x<118 and Y<118 is ''17. The result "Panel faulty" will be obtained. How can I write this code?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/665450/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/665450/image.jpeg)
0 comentarios
Respuesta aceptada
Image Analyst
el 25 de Jun. de 2021
With input() and a set of if tests:
% Enter [x, y], e.g. [4, 7]
xy = input('Enter x and y enclosed in brackets and separated by a comma: ')
x = xy(1)
y = xy(2)
if 0 < x && x < 58 && y > 120
uiwait(msgbox('Panel #1 is faulty'))
elseif 0 < x && x < 58 && y < 120
uiwait(msgbox('Panel #16 is faulty'))
%etc.
end
Adapt as needed.
Más respuestas (0)
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!