07-30-2014 09:26 AM
Hello,
I am trying to use matlab script in labview to post process the sampled signals from DAQ(attached is the vi I tried)
After every 10 seconds I want to the send the sampled voltage data to matlab scritp block which does 1) detection of peaks using peakdetection function and plots the obtained peaks on the sampled signal 2) calculates standard of 10 secs data and plots on chart.
But I am confused of 1) how to call the peakdetection function inside the matlabscript block
2) How to send the 10secs data of voltage and time values to the matlab script block
3) How to plot the signal and detected peaks on the same plot (which can be done in matlab using holdon as shown in the atached vi).
Can someone suggest for implementing these .
Thanks.
Solved! Go to Solution.
07-30-2014 09:54 AM - edited 07-30-2014 09:55 AM
@GoviRe wrote:
Hello,
I am trying to use matlab script in labview to post process the sampled signals from DAQ(attached is the vi I tried)
After every 10 seconds I want to the send the sampled voltage data to matlab scritp block which does 1) detection of peaks using peakdetection function and plots the obtained peaks on the sampled signal 2) calculates standard of 10 secs data and plots on chart.
But I am confused of 1) how to call the peakdetection function inside the matlabscript block
2) How to send the 10secs data of voltage and time values to the matlab script block
3) How to plot the signal and detected peaks on the same plot (which can be done in matlab using holdon as shown in the atached vi).
Can someone suggest for implementing these .
Thanks.
I am wondering why are you trying to do these things in Matlab script when LabVIEW already provides you handy. Did you try the Peak detection VI present in LabVIEW?
07-30-2014 10:01 AM
Hi P@Anand,
Because I want to develope a matlab script that can be later used to process the realtime data sampled using microconroller( where I dont use DAQ to sample the analog signals).I want to make sure that the matlab script works fine.
Can someone help me out implementing the above metioned things.
thanks.
07-31-2014 02:52 PM
08-01-2014 12:14 AM - edited 08-01-2014 12:14 AM
Hi GovRi,
You can try the attached vi to see if your Matlab script is working. You have to have the peakdet.m installed. If it works, then we can look at the best way to hook your DAQ up to the script node.
Good luck!
08-01-2014 08:10 AM
Hi GabeG,
I tried to use the vi you posted but I am getting some error as shown in the attached image.I also set the path to the directory in which the peakdet.m files resides using this tools->paths(as shown in the attached image).BTW,I am using Matlab R2011.
Can I get some help in fixing this issue.
thanks.
08-01-2014 06:29 PM
Hi GovRi,
I just incorporated peakdet into the script node and it works for me. Go ahead and try it again. Also I made a first stab at the data aquisition try it. The Matlab window should open as soon as you open the vi, if it doesn't there is a problem with the COM connection to Matlab.
Good luck!
08-02-2014 01:41 PM - edited 08-02-2014 01:46 PM
Thanks GabeG,
Now, Labview&Matlab_TestNoAq.vi is woking Good and for the second one Labview&Matlab_TestAq.vi it is showing error as shown in the attached image when these ines of code are present in the matlab scrtip
subplot(2,1,1),plot(maxtab(:,1),maxtab(:,2),'*r');
SDN=std(maxtab(:,1));
and SDN output of the Matlab script
but when I removed these it is working fine(but not showing the detected peaks).
Can you suggest me a solution for the above and also can I know the best method to add one more channel that samples another device signal which has to be processed in this same way(Signals sampled from 2 devices have to be porcessed in this same way).
Thanks.
08-03-2014 12:32 PM
Hi,
The error was being generated because peakdet didn't find any pulses in your signal which lead to Matlab trying to plot an empty array. I added in a check to see if the maxtab array is empty and if so, just put zero out of SDN and skip the peak locations plot. I also added a second channel.
Good luck!
08-11-2014 03:56 PM
Hi GabeG,
Is there any smart way to write and make use of the matlab functions in the matlab script block because I have to use multiple functions for my requirement.
Thankyou.