10-01-2013 01:28 PM
Hi
I have ta text file that has the following format. The apmlitude is the first value then I have the start index number and last index number
Other index values in between should be zero
(amplitide, start index number, end index number)
2, 2 ,3
4, 6, 7
5, 10,11
using this format I should make the foloowing array
0,0,2,2,0,0,4,4,0,0,5,5
Could you please help me to implement it in LabVIEW
Thanks
10-01-2013 01:34 PM
This looks like homework and seems quite trivial once you are familiar with array operations.
What have you tried so far?
10-01-2013 01:39 PM
Hi Tintin,
This is how I would go about it:
1) Initialize an array filled with zeroes, size = last index or however large you're going to need the array to be.
2) Pull out columns 2 and 3 from your spreadsheet, subtract 2 from 3 to give you the "index delta" for each row
3) Using column 1 and the new index delta array, initialize sub-arrays of value(amplitude/column 1) and size(index delta)
4) Use replace array subset and insert these sub-arrays at index(start index number) in the array we initialized in step 1)
This might be overkill, and depending on the size of your data sets may not be worth it- if your text file will always be sequential then you can probably just do an increment-index-and-check-value algorithm.
Regards,
10-01-2013 02:25 PM
Hi Outlaw
Could you please show me in a sample vi , I tried to follow your instruction but I don't understand part 3 and 4
Thanks
10-01-2013 02:37 PM
Show us what you got after doing steps 1 and 2.
10-01-2013 02:57 PM
Please find attached my vi
Thanks
10-01-2013 02:59 PM
please ignore my previous post
10-01-2013 03:14 PM
A few notes:
- You'll want to use the Initialize Array function for 1) and 3) (if this is, in fact, how you want to do this.) This function takes two inputs when initializing a 1D array- element value and array size.
- Change the polymorphic instance of Read From Spreadsheet File.vi to "Double" or "Integer"- there's no reason to read in these numeric values as strings and convert them later.
- Will the text file always contain 12 elements worth of data? If not, you'll need to change your logic for the number of elements to initialize.
As Altenbach said, this seems a lot like a basic logic/homework problem. My suggestion was only that-a suggestion. It is not the only way to do this. Figure out a sequence of steps to get you from point A to point B before you jump in and start coding.
Regards,
10-01-2013 03:23 PM
- Thanks for letteing me know, I will use Initialize Array function
-I will change to instance to double
-Yes, for now it has 12 elements
But my main problems are step 3 and 4. I don't understand how to do 3 and 4. Could you please help me on those part.
10-01-2013 03:32 PM
Search for the functions Initialize Array and also Replace Array Subset and read up on the information in the help file.