7

I have different callbacks in an Matlab App Designer App. In my case several buttons. I need to use the same variables for that.

I only get an error when using a variable I created in one Callback in another...

MrMond
  • 81
  • 1
  • 4

1 Answers1

6

I think I got your problem.

The easiest way is in beginning to create a new property (red button on the top left in EDITOR) and use it as a variable throughout the code.

Be careful to use app.variablename to address the variable.

If your code is already finished and you just discovered that error, you can set properties for only the variables you need to exchange and then get them like this:

set property:

properties (Access = private)
     varone %first variable
     vartwo % second variable
     ...
end

get Data for Exchange:

varone = app.varone; %(now you can use varone instead of app.varone)

make it public again at the end of your callback:

app.varone = varone;
Hamed
  • 202
  • 1
  • 4
  • 10
Kilian Weber
  • 160
  • 1
  • 8