HOW CAN I GET THE VALUE OF A VARIABLE OF A FUNCTION FILE TO USE IT IN OTHER FUNCTION FILE?
1 view (last 30 days)
Show older comments
Marcos Perez
on 31 Jul 2015
Answered: Walter Roberson
on 31 Jul 2015
%I attached the files a created.. I want to use the value of the variable 'density' to use it in the file report1.m
0 Comments
Accepted Answer
Walter Roberson
on 31 Jul 2015
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);
0 Comments
More Answers (0)
See Also
Categories
Find more on String Parsing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!