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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D array

Hello,

Can we create a 2d array (360x2) such that each element is added at specified index.Right now, I am using replace array subset which needs already existing array which needs to be initialised but I dont want to do that. Can u suggest me a best method to do so?

 

* I am using for loop for adding elements in replace array subset .....N=360, 'i' connected to both indices of rows and 0&1 to indices of columns.

0 Kudos
Message 1 of 6
(3,007 Views)

Hi,

 

I'm not sure I understood correctly, but do you know the auto indexing function? That should solve your problem. You can use a for loop inside another for loop to build a 2D array.

In general it is a good idea to initialize the array before as it's more performant normally.

 

Can you post an example of what you try to do or what you have already done?



Remember Cunningham's Law
0 Kudos
Message 2 of 6
(2,991 Views)

Hello,

I was trying to convert a cartesian to polar and save it in a tdms file.

0 Kudos
Message 3 of 6
(2,979 Views)

OK, so I'm going to start with the important things:

 

Why do you use a local variable here, when you could just connect everything that is now a variable?

The first for loop seems obsolete to me.

 

Aaaand, back to your original problem: you're not updating the array. You load the File fresh every iteration, read 2 values from it, insert them into the (very old) system numeric array 2 and write all of that into a tdms file. What you get is a tdms file that is 360 times as big as you originally intended and has 360 datasets with 1 updated row in it. As I suggested befor: Auto indexing is your friend:

Load the file once, pass the array to a for loop, in it convert, as you've already done, pass it out of the for loop (again, enabling auto indexing) and pass the result to the tdms function. If that doesn't work transpose the 2D array before and after. (not sure about the orientation you get from the file)

 

Other than that I hope you know that there's a boatload of free tutorials out there, which you access to get better acquainted with the old lady we call LabVIEW:

3 Hour Introduction
6 Hour Introduction
LabVEW Basics
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Learning NI
Getting Started with NI Products



Remember Cunningham's Law
Message 4 of 6
(2,966 Views)

Hello,

Actually I don't want to use any array at all.I just want  to take a file path (which consists a cartesian data) ,convert it to polar  and save in a tdms file.

0 Kudos
Message 5 of 6
(2,919 Views)
The Read from Spreadsheet returns a 2D array so you have to use that. Make the recommended changes with a single read and a for loop. Post back when that is done and if you still have problems.
0 Kudos
Message 6 of 6
(2,884 Views)