Use variable in two different functions
1 回表示 (過去 30 日間)
古いコメントを表示
I have to use variable defined in one function in another function. What should I use? I tried global but it fails with me
0 件のコメント
採用された回答
Azzi Abdelmalek
2016 年 4 月 3 日
編集済み: Azzi Abdelmalek
2016 年 4 月 3 日
[var1,...]=fcn1(...)
get the variable var1 from fcn1 and use it in fcn2
[...]=fcn2(var1,...)
5 件のコメント
Azzi Abdelmalek
2016 年 4 月 3 日
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
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!