Borrar filtros
Borrar filtros

Passing a matrix between several callbacks

1 visualización (últimos 30 días)
Luke
Luke el 25 de En. de 2023
Editada: Bjorn Gustavsson el 25 de En. de 2023
Im trying to write a program that analyses a matrix, I want to be able to have a button that opens and imports the matrix, which I do have and works great, then other buttons that perform different operations on that matrix. This is a problem as when I try to access the matrix variable from other callbacks the error Undefined Variable pops up. What is the best way that I can store a matrix for use in other callbacks?

Respuestas (1)

Bjorn Gustavsson
Bjorn Gustavsson el 25 de En. de 2023
Editada: Bjorn Gustavsson el 25 de En. de 2023
If you have all your user interface in one figure (some calculator-like programme), then one way to store the matrix is in the 'UserData' of the figure. For example:
set(gcf,'Userdata',pi*sqrt(2))
var_val = get(gcf,'UserData');
That way all UI-elements of the figure ought to have access to the matrix. If you want to do some more fancy calculator-emulation (HP15C for the win in all weathers!) you could have more complicated structures (a stack for example) in there.
HTH

Categorías

Más información sobre Interactive Control and Callbacks 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