11-26-2008 03:28 AM
Hi all,
The forum may flood with my question starting from now on [just joking ]
since I'm really new in LabView, there are tonnes of questions to ask - definitely the one that i cannot solved .
Currently, I'm having a 2D array which i want to convert to 1D.
I manage to do this by using the index array,as per in example attached (simplest way).
My question is, without knowing the total row of the 2D array, are we able to extract each row as 1D array for display purpose?
Any suggestion guyz so that i can move forward?
Please advise and million of thank you in advance~
regards,
Roziela Sharib
Solved! Go to Solution.
11-26-2008 03:40 AM
Is the idea to present 1 row at a time? If so, you can connect the Index Array row selector to a numeric control.
If you're wondering how it'll handle as the table grows you can connect it to a for-loop which'll be autoindexed to the full table size.
/Y
11-26-2008 03:55 AM
Hi Yamaeda~
Thank you for your reply.
This is the answer for your question :
Q: Is the idea to present 1 row at a time?
A: It is best to say that the idea is to have all row at one time. Display is not necessary because the idea is to have the data for graph plotting.
Well, actually I was thinking of convert this 2D array to 1D.
Each 1D array represent one plot.
After that, each plots are to be display on the waveform graph.
This is the sequence that i have in mind.
Several 2D arrays --> convert all 2Ds to 1Ds --> Now Plotting all the 1Ds to graph.
The major problem now is i cannot fixed my row and column value since this parameter is defined by user.
Please advise, and thank you again Yamaeda for your reply.
regards,
Roziela Sharib
11-26-2008 04:10 AM
11-26-2008 04:47 AM
You basically want to do a multigraph plot from a Xd-array?
Would this sketch work out?
(loops can ofc be added for nicer environment and stuff)
/Y
11-26-2008 07:32 AM
It sounds like you are asking for the "Index Array" function found on the Array palette. It has an input for any type of an array as well as index terminals that will let you select individual elements or rows.
Ben
11-26-2008 07:02 PM
Hi all~
Thank you for your reply..
Really appreciate that..
Hi Yamaeda..
Thanks for the attachment.
The 2D to 1D[1].png is OK, but it's just displaying the array one by one and at the end(Its good if i can capture each and every row )
I only manage to get the last value to be send to next operation (for this case,it is plotting a graph)
For multigraph.PNG, your output is exactly as what i expected.
However, you are fixing the number of inputs to it by sending dimension size & dimension size 2 to the number of columns and rows to the property node of the initialized array~
For my case, the number of rows and columns is not going to be consistent at all time (esp row (selected parameters) since i have fixed data points in one day which represent by the column elements).
Index array do helps a lot (as what i have in my 2D_to_1D.vi attached) but to have all the rows, i need to have fixed numbers of the index array right?
Please advise if my understanding is wrong.
Thanks a million for all the feedback guyz.. It helps a lot..
regards,
Roziela Sharib
11-26-2008 08:32 PM
Hi Roziela,
You can use an Array Size function in conjunction with the Index Array in able to obtain the maximum row index usable, irregardless of the size of the array or whether if you have knowledge of the number of elements in each dimension.
I edited your VI to show the said example. The array size function returns the number of elements in each dimension through a 1D array result. The row dimension is at the first element. Using this result, you'd only need to subtract one to obtain the maximum row index (thus the last available subarray) for any 2D array you'd prefer to use
Best Regards,
JoshuaD
11-26-2008 08:33 PM
Hi Roziela,
You can use an Array Size function in conjunction with the Index Array in able to obtain the maximum row index usable, irregardless of the size of the array or whether if you have knowledge of the number of elements in each dimension.
I edited your VI to show the said example. The array size function returns the number of elements in each dimension through a 1D array result. The row dimension is at the first element. Using this result, you'd only need to subtract one to obtain the maximum row index (thus the last available subarray) for any 2D array you'd prefer to use.
Best Regards,
JoshuaD
11-26-2008 08:46 PM