Initialize huge variables on xPC target
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am looking for a possibility to initialize huge variables on the xPC target. That variable should contain a huge matrix and be is required to read out few values and overwrite some values at each time step. It should not forget the values I wrote into it while the program is running.
I tried with defining it as persistent variable in an embedded m-file - and basically it works, but of course it is not initilized at the first start. Therefore I put a
if isempty(varialename) variablename = zeros(dim1,dim2)
in the m-file.
As this variable is too big, that command takes too long and I get a cpu overload error.
Thats why I want to initilize it before the system started... Any ideas?
Is there a compiler command allowing this? Or even something simpler? Thanks!
0 Kommentare
Antworten (1)
Gordon Weast
am 10 Feb. 2012
To satisfy all your requirements, you might need to write your own S-function. Then use the target disk to save the values at stop time and restore them in mdlStart when you start the model again.
You can use file system calls inside your S-function. Do the file IO in mdlStart and mdlTerminate. You can use malloc() to allocate the buffer. Save the pointer in a P-work variable. Match allocation in mdlStart with freeing in mdlTerminate or you'll see a memory leak.
This does require that you have a disk with a FAT file system on it. You'll be able to read/write the file with the data from the host to set up the initial values and recover the final values.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!