I have a question about GUI with Code
4 次查看(过去 30 天)
显示 更早的评论
Hello, I have a code that I did not make, but I took it from a book, I want to execute the code for a thesis, but the code is written for a GUI interface, my question is, if the code that I have can be execute and have the GUI interface appear without me making the interface, how do I do it? And if it can't be done... should I make the interface? I share the first lines of the code that I took from the book.
% --- Executes on button press in ce.
function ce_Callback(hObject, eventdata, handles)
clc; cla(handles.grafica);
nro=str2double(get(handles.nro,'string')); V=str2double(get(handles.V,'string'));
nct=str2double(get(handles.nct,'string')); ncf=str2double(get(handles.ncf,'string'));
ccond=str2double(get(handles.ccond,'string')); Y=str2double(get(handles.Y,'string'));
h=str2double(get(handles.h,'string')); n=str2double(get(handles.n,'string'));
0 个评论
回答(1 个)
Taylor
2024-10-21,15:23
You can definitely edit this code to function without the GUI. You won't need hObject or eventdata; these are variables specific to the GUI. But the structure handles contains the information that is actually used in the function block. Generally, the code is just taking fields from handles that contain strings, converting them to double values with str2double, and storing the new double values in their own variables outside of the original structure.
1 个评论
Walter Roberson
2024-10-21,16:45
the code is just taking fields from handles that contain strings
It would be a bit of a nuisance to create a class that contains a property named string in order for the get() of 'string' to work -- but it is certainly do-able. Overall it might be easier to replace
get(handles.nro,'string')
with
handles.nro.string
and make corresponding changes to the setting code.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!