Hi, i want to know how i can extract the GUI code to form a code without using GUI command?

3 views (last 30 days)
global fov
set(handles.fov_txt,'String',temp{1,1})
fov=str2double(get(handles.fov_txt,'String'));
Here are the code but it's in GUI. i want to make the fov variable to be put in the "dbch".
k_aa=300;
resizeFactorOD=round(k_aa/minAxisLen,2);
dbch = {[fov, minAxisLen*resizeFactorOD ]};
pxr = cellfun( @(x)x(2)/x(1) , dbch )';
lowerlimit=round((pxr*3)); upperlimit=round(lowerlimit*1.5);
I hope someone can help :)
  3 Comments
dpb
dpb on 2 Jan 2022
Edited: dpb on 2 Jan 2022
Well,
global fov
set(handles.fov_txt,'String',temp{1,1})
fov=str2double(get(handles.fov_txt,'String'));
is only going to be functional inside the context in which the handle of the text object handles.fov_txt is in scope and while the object exists. The content of that object should be in the new dbch cell array, but that also will have to execute in the same context and time as the above for fov to be in scope in order to create the variable.
If you're trying to rely on global to make the content of fov be available to another piece of code, then that other code must also include
global fov
and that code must also execute while the global context in which the other piece of code is still in context. This is not a reliable way to write code...if the GUI needs to create this variable and another piece of code needs to pick it up, it would be more robust to have the GUI save the value to a .mat file that the second code reads/loads.

Sign in to comment.

Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!