How do I pass variable from one function to another

2 次查看(过去 30 天)
Hi!
How can I make this code work? I can't seem to find a way to pass variable 'v' to a different local function.
Tahnk you!
function [v] = Popup(obj, handles , h_listbox)
parameters=detectImportOptions('Data.xlsx');
v = get(obj,'Value');
disp(v)
set(h_listbox,'String',datestr(readvars('Data.xlsx',parameters,'Sheet',v)))
end
function Listbox(obj,h_popupmenu ,h_8things, handles)
k = get(obj,'Value');
Data = (readmatrix("Data.xlsx","Range",'B2:X32','Sheet', v));
polarhistogram(Data(k,:),16)
end

采纳的回答

Voss
Voss 2022-1-16
How about this?
function [v] = Popup(obj, handles , h_listbox)
parameters=detectImportOptions('Data.xlsx');
v = get(obj,'Value');
disp(v)
set(h_listbox,'String',datestr(readvars('Data.xlsx',parameters,'Sheet',v)))
end
function Listbox(obj,h_popupmenu ,h_8things, handles)
k = get(obj,'Value');
Data = (readmatrix("Data.xlsx","Range",'B2:X32','Sheet', get(h_popupmenu,'Value')));
polarhistogram(Data(k,:),16)
end
If that doesn't work, we would have to see how the callbacks are set.
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by