Initialize huge variables on xPC target

조회 수: 5 (최근 30일)
Chris
Chris 2012년 1월 11일
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!

답변 (1개)

Gordon Weast
Gordon Weast 2012년 2월 10일
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.

카테고리

Help CenterFile Exchange에서 Multicore Processor Targets에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by