how do you put condition in GUI?

16 Ansichten (letzte 30 Tage)
Bedivere Cabahug
Bedivere Cabahug am 13 Jul. 2022
Kommentiert: Bedivere Cabahug am 13 Jul. 2022
% I would like to put a condition that t3 is greater than t4,t2, and t1,t2 is less than t4 and t2>t1
% --- Executes on button press in Calculate.
function Calculate_Callback(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of Calculate
t1=str2double(get(handles.T1,'string'));
t2=str2double(get(handles.T2,'string'));
t3=str2double(get(handles.T3,'string'));
t4=str2double(get(handles.T4,'string'));
Nth=(1-((t4-t1)/(t3-t2)))*100;
set(handles.OUT1,'string',num2str(Nth));

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Jul. 2022
if all(t3 > [t4, t2]) && all([t1,t2] < t4) && t2 > t1
Nth = (1-((t4-t1)/(t3-t2)))*100;
set(handles.OUT1,'string',num2str(Nth));
else
handles.OUT1.String = 'Invalid inputs';
end
  1 Kommentar
Bedivere Cabahug
Bedivere Cabahug am 13 Jul. 2022
your god given angel :) thank you so much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Just for fun finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by