HOW CAN I GET THE VALUE OF A VARIABLE OF A FUNCTION FILE TO USE IT IN OTHER FUNCTION FILE?

 Accepted Answer

You do not have a variable named "density". You have a text field that contains the word DENSITY and you have an edit field that you store values in as a string.
What you would do is use pass the handle of the first figure into guidata() to retrieve the handles structure belonging to the first figure, and then
str2double( get(handles.edit3, 'String') )
would get you the numeric equivalent of the field.
But inside REPORT1 you do not normally know what the figure handle is for the figure for PROG1. So you have to find it:
prog1_fig = findall(0,'NAME','PROG1');
prog1_handles = guidata(prog1_fig);
prog1_density_handle = prog1_handles.edit3;
report1_fig = findall(0,'NAME', 'REPORT1');
report1_handles = guidata(report1_fig);
report1_density_handle = report1_handles.edit1;
prog1_density_string = get(prog1_density_handle,'String');
set(report1_density_handle, 'string', prog1_density_string);

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!