LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab Script more slow each in call? Is 'Clear all' command a solution?

Hello,

 

I'm using the Matlab script to perform signal processing in the LabView application. Some time ago I realised that the application goes slowly over the time (the applications achieves times up to 10 min in one day when it begins with 3 min).

 

Firstly, I thought that the problem was an array that was growing in the time but I have checked it and it is not the problem. After many tests I have found a clue. When I execute "clear all" in the Matlab Command window, the LabVIEW application returns to the initial speed but it follows the same behaviour (goes again slowly over time). What is the problem here? I have checked the variables with the command "whos" and the variables don't grow in the time, the variables are always the same. So, I understand that the speed shouldn't change. 

 

I have tried to call "clear all" inside the LabVIEW code with another Matlab Script but it doesn't work properly and the speed is still degraded. 

 

I have three different Matlab Script that are running inside a loop, so the scripts are called many times. I understand that the performance should be the same all the time... I don't understand why it gets more slowly. 

 

I will apreciate any comment or idea explaining it. 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 7
(3,868 Views)

I have the same issue! More interestingly, I've found that *any* command (even a blank line) manually entered into the Command Window will return the VI to its original speed. Like yours, mine will eventually slow back down as well.

 

I've also found that the MATLAB process takes up increasing amounts of memory in Task Manager as it runs. Memory usage is not affected by the speed-up process described above.

 

Note: I am using MATLAB script to stream data from another device.

0 Kudos
Message 2 of 7
(3,653 Views)

Hey Luisi,

 

Couple things, I could see there be a lot of overhead with using a timed loop, matlab script node, and waveform charts in one VI, you may want to try either dividing your processes or removing them all and adding them in one at a time to see where the bottleneck is.  I'd also try just using a while loop to see if that helps the overhead.  Adding a wait(ms) of 10ms should get the same behavior as the timed loop.

 

It's odd that it just comes back with the clear all/return being pressed.  Is the acquisition itself being slowed down?  You can check this by logging some data and once it slows down, seeing if the logging also slows.  Or  I would guess the Waveform Chart would jump to a later time if this was true as well.

 

 

Also, is this affecting your overall workflow?  Are you hoping that someone has a work around, or do you need this fixed?  Possible workaround is programmatically calling the return key and seeing if that has the same affect of "resetting" the UI.

 

-Ben

Regards,

Ben Johnson
ʕง•ᴥ•ʔง
0 Kudos
Message 3 of 7
(3,621 Views)

@TheEngineeringBear wrote:

 

Couple things, I could see there be a lot of overhead with using a timed loop, matlab script node, and waveform charts in one VI, you may want to try either dividing your processes or removing them all and adding them in one at a time to see where the bottleneck is.


Are there missing posts? I cannot find the the descriptions where it talks about the use of time loops, charts, etc. What post are you replying to?

 

Do the various matlab script nodes execute in sequence or do they operate in parallel?

0 Kudos
Message 4 of 7
(3,615 Views)

Hi Ben,

 

I've tried programmatically calling clear command programmatically between other calls, but that does not seem to prevent process slowdown. I believe acquisition is slowed down, as I know that data gets dropped once slowing occurs. We use a timed loop because we need to maintain consistent time between iterations and want to prioritize that particular loop.

 

It's important for our team to understand this hiccup, as we would like to continue using MATLAB script in this application and future ones for heavy matrix calculations. This idiosyncratic behavior is very odd though.

 

How does one programmatically call the return key in MATLAB script?

0 Kudos
Message 5 of 7
(3,602 Views)

Hi altenbach,

 

The MATLAB scripts are all running in sequence. Different calls are made to MATLAB in a state machine in a timed loop. Data produced by that loop are then fed into a queue for number crunching and display in other consumer loops.

0 Kudos
Message 6 of 7
(3,591 Views)

Hi Ben,

 

I've just had a chance to try out all of your suggestions:

  • replacing timed loop with a while loop and a wait
  • removing front panel displays (except for one chart to observe the chugging

Behavior appears unchanged: VI still chugs after some time, data is still dropped, and hitting return in the MATLAB command window speeds things right back up. I haven't been able to figure out how to programmatically hit the return key in MATLAB, so I have not tried that.

 

Please advise.

 

Thanks,

0 Kudos
Message 7 of 7
(3,554 Views)