LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

vector to matrix tranformation

Hi, I have made up a little example that reads a table from the UIR, transposes it and displays data on an output table.

This is done by reading data in a single array and passing it to Transpose.

 

An interesting trick of tables is that you can obtain the same effect by reading data in column major order and writing them back in row major order (or vice-versa): this method also is included in the example.

 

You could think to use it in your app duplicating the original table in a new, hidden one to use only for transposition of the matrix: read transposed data back from the new table and discard it afterwards.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 11 of 13
(960 Views)

Hi cat87,

 

 

Something like this should work for what you are doing.

 

 

    int vector[100] = {0};
    int matrix[10][10] = {0};
   

//Fake Data

   for (int hundred = 0; hundred<100; hundred++)
    {
   
        vector[hundred]=hundred;
    }
        
//Into Matrix   

for (int tens = 0; tens < 10; tens++)
    {
        for(int ones = 0; ones <10; ones++)
        {
           
            matrix[tens][ones]=vector[(10*tens)+ones]; //(10*tens)+ones = the absoulte index of the vector    

         }
    }
   
   
    Hope this helps!

 

Regards,

Message Edited by Dustin D on 06-15-2010 12:05 PM
Dustin D

0 Kudos
Message 12 of 13
(929 Views)

Hi Dustin,

 

in my contribution to this problem I was trying to suggest that readable code is a valuable aspect - trying to avoid calling a vector 'matrix'... In that sense your sample code

 

hundred = 0; hundred<100; hundred++

 

is not exactly what I had in mind Smiley Wink

0 Kudos
Message 13 of 13
(913 Views)