From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measure

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire data using Labview VI and process in matlab.

hello,

        I wish to read data for two analog inputs using a NI DAQ USB 6356 and process it in matlab. I do not have matlab data acquisition toolbox. My Matlab code includes a mex file. I am planning  to start with an example vi for data acquisition and put into it a matlab script node which would have my matlab code and will also call the mex file. I just want to know if this method is at all possible or if there is a better way to do it. At this time it would be sufficient if I just get a fixed number of samples and send it to Matlab, i.e I do not need any real time processing.

 

Umar.

0 Kudos
Message 1 of 6
(8,565 Views)

Hi Umar,

 

National Instruments offers a toolkit written in LabVIEW that allows the use of DAQ hardware from within Matlab itself. As you wish to acquire finite samples the "AcqNSamples.m" example included with the toolkit would be most suitable for your application.

 

The "NI-DAQmx Tools for Data Acquisition with The Mathworks, Inc. MATLAB® Software" is available free from the link here.

 

This toolkit differs from the "Matlab Data Acquisition Toolbox" detailed in your forum post.

 

Please let me know if this assists with your application Umar.

 

Many Thanks

Jamie S.

Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(8,555 Views)

hello,

          I tried the tool box and get the following error

 

>> [data, time, initial_time, timed_out] = AcqNUpdates('dev1/ai0', -10, 10, 100000, 1000000, 10)

 

Error: File: AcqNUpdates_nonUI.m Line: 1 Column: 160 Unbalanced or unexpected parenthesis or bracket.

 

Error in AcqNUpdates (line 120) [data, time, initial_time, code, source, status] = AcqNUpdates_nonUI(Physical_Channel, Minimum_Value, Maximum_Value, Samples_per_Channel, Sample_Rate, Timeout);

 

I am using Matlab R2011b(7.13). Can you please tell me how the problem can be solved?

 

Best regards,

                       Umar Khan.

 

0 Kudos
Message 3 of 6
(8,537 Views)

Hi Umar,

Unfortunately we do not have Matlab within the office here so I'm unable to replicate your issue. On searching the details of the error you're experiencing on the MathWorks(R) website the explaination behind the error is:

 

Explanation:The number of left parenthesis is not equal to the number of right parenthesis in your expression.

 

Common causes:You added a left parenthesis or removed a right parenthesis from the line of code.

 

Solution: Count the number of left parentheses and right parentheses on the line of code. Verify that the quantity of the two types of parentheses are equal. Add in an appropriate number of right parentheses or remove extraneous left parentheses.

 

This suggests that the number of opening brackets does not equal the number of closing brackets, however on reviewing your code it seems that this is not the case. Would it be possible to run the Matlab Toolbox code on an older version of Matlab? It may also be worth reducing the "Samples_per_Channel" and "Sample_Rate" to much lower levels to see if the code executes.

 

Another solution might involve sampling the data within LabVIEW and then exporting the data to a *.csv data file which can then be easily imported for analysis within Matlab 2011. In this case invoking Matlab following data acquisition using a "Matlab Script Node" would be the best option.

 

Kind Regards

Jamie S.

Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(8,516 Views)

Hi,

 

I also have the problem. Now I want to acquire data from 4 sensors in LabVIEW. Then in MATLAB I have an algorithm to solve these data. How can I transfer data from LabVIEW to Matlab automatically to compute them?

Thank you very much.

 

Hieu

0 Kudos
Message 5 of 6
(7,437 Views)
This is really the wrong place to post your question. Measure is an obsolete product. It was an add-on for excel.
0 Kudos
Message 6 of 6
(7,433 Views)