Filter löschen
Filter löschen

Use variable in two different functions

5 Ansichten (letzte 30 Tage)
Ali Jaber
Ali Jaber am 3 Apr. 2016
Kommentiert: Azzi Abdelmalek am 3 Apr. 2016
I have to use variable defined in one function in another function. What should I use? I tried global but it fails with me

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 3 Apr. 2016
Bearbeitet: Azzi Abdelmalek am 3 Apr. 2016
[var1,...]=fcn1(...)
get the variable var1 from fcn1 and use it in fcn2
[...]=fcn2(var1,...)
  5 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 3 Apr. 2016
You could precise that you are using Guide Matlab. you can share data with guidata function
function btnVisualDataset_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile('*.xlsx','Load Dataset');
if filename==0
msgbox('Please Choose Dataset','Error','Error')
return
end
for i=1:10
data = xlsread(filename);
mv{i}=[data(:,i)];
handles.mv=mv;
guidata(hObject,handles)
end
function btnSearch_Callback(hObject, eventdata, handles)
mv=handles.mv
end
Azzi Abdelmalek
Azzi Abdelmalek am 3 Apr. 2016
You already get the answer

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by