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:
Invokes slow down as time goes by

Subject: Invokes slow down as time goes by

From: Alex

Date: 17 Feb, 2012 13:38:37

Message: 1 of 4

Dear all.
I am using matlab to control externally a meauserement device (For example a S.A).
I have noticed that as the time goes by the time the code needs to be exectuted increases.

For example the first two days the code needs 0.300 secs to complete.
after two days the code takes around 1 sec
while after the 5th day the code needs around 30 secs!

The problem is not in the laptop resources (4 cores at 25% cpu utilization) and 3 gigabytes out of 4 are always free.


I have placed many tic toc points in the code to pritn the execution time. I have found that all the matlab specific code works well and there is no increase int the time it takes to be executed.

The problem seems to be from the invokes I do in code to get data from the device.

For example


tic;
    try
      invoke(saDev.frequencygroup, 'confspancenterfrq', measWindow, 0, frqspannow, frqcentnow);
    catch
      disp('Problem with setting frqcent');
      break
    end
ca=toc;
tic;
    try
      invoke(saDev.inputgroup, 'confrfinatt', measWindow, attenuationnow); % input att
    catch
      disp('Problem with setting attenuation');
      break;
    end
d=toc;


These invokes are where the time needed for execution increases...

The problem also does not seem to be hardware specific. Even if I turn off the hardware or swap it the time will keep being increased. The problem is only solved when I close the gui which unloads the driver and I relaunch it again.

Anything to suggest?
Regards
Alex

Subject: Invokes slow down as time goes by

From: Steven_Lord

Date: 21 Feb, 2012 16:25:55

Message: 2 of 4



"Alex " <alaios@yahoo.com> wrote in message
news:jhll8t$bjh$1@newscl01ah.mathworks.com...
> Dear all.
> I am using matlab to control externally a meauserement device (For example
> a S.A). I have noticed that as the time goes by the time the code needs to
> be exectuted increases.
>
> For example the first two days the code needs 0.300 secs to complete.
> after two days the code takes around 1 sec
> while after the 5th day the code needs around 30 secs!
>
> The problem is not in the laptop resources (4 cores at 25% cpu
> utilization) and 3 gigabytes out of 4 are always free.
>
>
> I have placed many tic toc points in the code to pritn the execution time.
> I have found that all the matlab specific code works well and there is no
> increase int the time it takes to be executed.
> The problem seems to be from the invokes I do in code to get data from the
> device.

*snip*

> These invokes are where the time needed for execution increases...
>
> The problem also does not seem to be hardware specific. Even if I turn off
> the hardware or swap it the time will keep being increased. The problem is
> only solved when I close the gui which unloads the driver and I relaunch
> it again.

You mention that there's a GUI involved ... are you doing something like:

axis([0 10001 -1 1]);
hold on
for k = 1:10000
    plot(k, sin(k));
end

If so, that code is plotting 10000 lines (each of which contains one point)
on the axes, not just one line containing 10000 points. If you're doing that
and plotting hundreds of thousands or millions of lines, the slowdown could
be in your plotting code not your data acquisition code. Instead, take a
look at some of the techniques in this documentation:

http://www.mathworks.com/help/techdoc/creating_plots/f10-1460.html

I would probably use the third approach.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Invokes slow down as time goes by

From: Alex

Date: 24 Feb, 2012 08:49:23

Message: 3 of 4

I would like to thank you for your answer.
No I am not plotting anything... it is just a gui where I am updating the time intervals and few counter values. Apart from that I am also appending the entries I Get from the device to a file

Regards
Alex

Subject: Invokes slow down as time goes by

From: Steven_Lord

Date: 24 Feb, 2012 14:31:17

Message: 4 of 4



"Alex " <alaios@yahoo.com> wrote in message
news:ji7iui$1io$1@newscl01ah.mathworks.com...
> I would like to thank you for your answer.
> No I am not plotting anything... it is just a gui where I am updating the
> time intervals and few counter values. Apart from that I am also appending
> the entries I Get from the device to a file

Please show the code you're using to append the data to the file.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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