Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
persistent variables in shared library for tracking application

Subject: persistent variables in shared library for tracking application

From: aniket

Date: 28 Jul, 2011 09:23:13

Message: 1 of 3

hi i am creating a c shared library using matlab for a tracking application. Its a function that is called every frame from a C program. I want to keep account of the previously tracked point within the matlab code itself and not make the data visible to the C program. Currently I have thought of storing the coordinates in a .mat file that open inside my m file. But I was wondering if there was any way like persistent variables that would keep these coordinates in memory between function calls. Or any other idea on how to solve this.
Well thanks in advance...

Subject: persistent variables in shared library for tracking application

From: Pierre

Date: 28 Jul, 2011 12:49:13

Message: 2 of 3

"aniket" wrote in message <j0r9q1$5je$1@newscl01ah.mathworks.com>...
> [...] But I was wondering if there was any way like persistent variables that would keep these coordinates in memory between function calls. [...]

Well, as you already pointed out... "persistent variables"!!!

persistent foo;
if isempty(foo)
    foo = initialize();
end

;P

Subject: persistent variables in shared library for tracking application

From: Scott

Date: 28 Jul, 2011 15:05:30

Message: 3 of 3

"aniket" wrote in message <j0r9q1$5je$1@newscl01ah.mathworks.com>...
> hi i am creating a c shared library using matlab for a tracking application. Its a function that is called every frame from a C program. I want to keep account of the previously tracked point within the matlab code itself and not make the data visible to the C program. Currently I have thought of storing the coordinates in a .mat file that open inside my m file. But I was wondering if there was any way like persistent variables that would keep these coordinates in memory between function calls. Or any other idea on how to solve this.
> Well thanks in advance...

You could also nest your functions so that they see your common variables. Very fast too.

Scott

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us