Clear Filters
Clear Filters

Set variables from other GUIDE with the command Varargin.

2 views (last 30 days)
Hello people, I made two Interfaces with GUIDE so the first one called it Index, which one the user type some numbers and the other one called it Results, get them, showing the typed numbers like i do with this code:
INDEX:
Here I get all the numers and transfer them to the next interface
l=str2double(get(handles.Longitud,'String'));
h=str2double(get(handles.Peralte,'String'));
b=str2double(get(handles.Patin,'String'));
c=str2double(get(handles.Carga,'String'));
e=str2double(get(handles.E,'String'));
results(l,h,b,c,e)
And "results" get those variables with this code:
function results_OpeningFcn(hObject, eventdata, handles, varargin)
set(handles.v1, 'String',varargin(1,1));
set(handles.v2, 'String',varargin(1,2));
set(handles.v3, 'String',varargin(1,3));
set(handles.v4, 'String',varargin(1,4));
set(handles.v5, 'String',varargin(1,5));
That works but when I want to use those same number in other function trying to call them and get them in variables respectively it doesn't works, some one could explain me, how can I get those number for use them in other calculations? this is the code that I made for it:
function graficar2d_Callback(hObject, eventdata, handles)
L=set(varargin(1,1));
H=set(varargin(1,2));
B=set(varargin(1,3));
C=set(varargin(1,4));
E=set(varargin(1,5));
I=(B*H^3)/12;
x=linspace(0,5,100);
y=(C/(2*E*I));
axes(handles.grafico3d)
plot(x,y);
Thanks for the answers and sorry for my english, I'm from Colombia so I'm still tryin' on it

Answers (1)

Harsha Priya Daggubati
Harsha Priya Daggubati on 14 May 2020
Hi,
The above code does not work as each callback has it's own workspace. Inorder to share data between callbacks of the UI elements in GUIDE, you have multiple ways. You can refer the following documentation link, to help you through
Hope this helps!

Categories

Find more on Migrate GUIDE Apps 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!