First, I have had a look at this excellent article already.
I have a MATLAB script, called sdp
. I have another MATLAB script called track
. I run track
after sdp
, as track
uses some of the outputs from sdp
. To run track I need to call a function called action
many many times. I have action
defined as a function in a separate MATLAB file. Each call of this action
has some inputs, say x1,x2,x3
, but x2,x3
are just "data" which will never change. They were the same in sdp
, same in track
, and will remain the same in action
. Here, x2,x3
are huge matrices. And there are many of them (think like x2,x3,...x10
)
The lame way is to define x2,x3
as global in sdp and then in track, so I can call action with only x1
. But this slows down my performance incredibly. How can I call action again and again with only x1
such that it remembers what x2,x3
are? Each call is very fast, and if I do this inline for example, it is super fast.
Perhaps I can use some persistent variables. But I don't understand exactly if they are applicable to my example. I don't know how to use them exactly either.