LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

input 6*4*100 3D matrix from matlab to labview

Hi everyone,

 

I have computed  6*4*100 3D matrix (i.e. the rank number of the matrix is 6, the column is 4, and there are together 100 matries like this ) in Matlab before, and now want to input them into Labview for further application.

 

Could anyone give me some suggestions to do this in Labview?

 

THX very much!

 

 

Cheers

0 Kudos
Message 1 of 7
(4,120 Views)

I have computed  6*4*100 3D matrix (i.e. the rank number of the matrix is 6, the column is 4, and there are together 100 matries like this ) in Matlab before, and now want to input them into Labview for further application.

 

Could anyone give me some suggestions to do this in Labview?


The important question is how the numbers are saved in the file.  Are they strings?  Integers?  Floats?  What size (I32, Sgl, Dbl)?  Is the byte order the same for Matlab and LabVIEW?  Does Matlab prepend size information when it writes the array?

 

I just did a little demo for myself, since I'd not (yet) worked with 3D arrays in LabVIEW.  I generated 24 integers (from 0 .. 23), made an array with 2 rows, 3 columns, and 4 whatevers, wrote them to a binary file with the default "prepend array size", closed the file, then looked at it.  Here's the code:

Array Write test.png

Here's what I found.  Everything was 4-byte integers (I32).  The contents were 2, 3, 4, 0, 1, ... 23.  That is, the three dimensions and the 24 values. 

 

Reading works similarly,  Wire an empty I32 array having three dimensions to the Type input of the Read.  You end up with a 2x3x4 matrix containing your numbers.  Note that the first index (which can be 0 or 1, i.e. size 2) has what looks like a 3x4 array, the first being 0..11, the second 12..23.  The arrays have 4 columns and 3 rows (so my description above was wrong).

 

Very straightforward.

 

Bob Schor

 

0 Kudos
Message 2 of 7
(4,105 Views)

Dear Bob,

 

Thanks very much for your immediate reply! 

 

I think I did not express my meaning well in last post.

 

I mean, the 6*4*100 matrix have been obtained in matlab already like this (  only the first five matries have been captured on the figure) 

Capture.PNG 

 

These matries are saved in matlab as the .mat file. But they can also be copied and then saved in txt file.

 

What I want to do is to input the 100 matries into the time loop in Labview. At each sampling time (5ms), one 6*4 matrix will be input into the time loop for computation. therefore, the time loop will sample together 100 times.

 

Thanks very much!

 

Cheers

 

 

 

 

 

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

Hello Stanley,

 

I am stucked in a very similar situation. Could you please let me know if you have already got the solution to this problem?

I also want to get my .mat file from MATLAB to LabVIEW.

The file contains a 3D matrix with 121*121*231 data.

I have already tried with the 'Data Storage' .MAT plugin but it seems to support only for 2D matrices.

 

Request you or anyone to please help in this regards.

 

Thanks

Rahul

Knorr- Bremse, Munich

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

Hello Stanley,

 

perhaps best would be, to save your values in a txt- file and post a sample of it. Then it's much easier to give the appropriate advices.

 

Greets, Dave
0 Kudos
Message 5 of 7
(3,808 Views)

Dear Stanley and Rahul,

 

     I believe the .mat format is a proprietary Matlab file format, with multiple versions and featuring file compression.  When a colleague sent me .mat files to analyze, I wrote a small "Mat to Dat" function in Matlab that looked for .mat files, loaded the Variable in Matlab, opened a .dat file (of the same name, e.g. "My Data.mat -> My Data.dat") and wrote the data out.

 

     Since what you get is a simple Binary file, it is fairly simple to read these data back into LabVIEW, as I demonstrated in an earlier post to this topic -- you (of course) need to know the data format (I32, Sgl, Dbl, etc.).

 

Bob Schor

0 Kudos
Message 6 of 7
(3,769 Views)
Thanks Bob
now I'm able to get the 3D array from Matlab to labview 😊
0 Kudos
Message 7 of 7
(3,735 Views)