Use variable in two different functions
4 次查看(过去 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!