How do I pass variable from one function to another

2 visualizaciones (últimos 30 días)
Abrathamist
Abrathamist el 16 de En. de 2022
Comentada: Voss el 16 de En. de 2022
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

Respuesta aceptada

Voss
Voss el 16 de En. de 2022
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 comentarios
Abrathamist
Abrathamist el 16 de En. de 2022
That works great! Thank you so much!
Voss
Voss el 16 de En. de 2022
Excellent! Glad it is working.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by