LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting String Array to Integer string

Solved!
Go to solution

I have two text files with numbers (signal1.txt and signal2.txt). I want to convert them to Integer array and have a process on them. When I converted them by Fract/Exp String To Number control, it shows just 0 (You can see in the attached file). How can I have the correct numbers?

Download All
0 Kudos
Message 1 of 22
(4,500 Views)

Well your converting the numbers properyl.  That isnt the problem.

 

You get the 0 everytime because you are doing the "process" on the 0 index of your array every iteration, which happens to be zero.  I would consider doing away with the case structures and putting the process in a for loop for the smaller array size of iterations.  Then i would index my array based on the iteration of the for loop. 

 

[Edit] if youre attempting to only do the addition when elements are present in both arrays, labview will only do the process on the smallest array, it does not assume 0 when there is no element present.  Smiley Very Happy

 

Hope that helps.



-Matt
0 Kudos
Message 2 of 22
(4,479 Views)

Your two converted arrays look just fine to me.

 

I'm wondering what you are trying to do in the 2nd frame of your sequence structure.  There you are just indexing out element 0 of both arrays repeatedly.

0 Kudos
Message 3 of 22
(4,476 Views)

Looking at the code, I get the impression that you are new to LabVIEW.

 

I suggest that simplify your problem statement.

 

You might want to focus on how to properly read a file in the first place.

 

 

From what you are trying to do, LabVIEW developwers have already done it for you in examples. At least in piecewise chunks. You just need to dig in a bit.

Take a look at the examples provided in the detailed help.

You should find some clues on what you need to do.

 

I have no idea what you are trying to do in your process, but it looks overly complicated.

Once again the examples can help you here as well. Look up array manipulation.

--good luck

simplePointerToAnswers.png


Engineering - The art of applied creativity  ~Theo Sutton
0 Kudos
Message 4 of 22
(4,469 Views)

I use the index zero to compare two elements in two arrays and based on some circumstances I remove the first element of each array (maybe one array is affected maybe both of them). Then I compare the element in index 0 again. It means I should compare the first element in each iteration. This matter is continuing till at least one array becomes empty. When I try it with an ordinary array it works but when I use a converted one it does not work and I guess removing items from a converted array is impossible. Please look at the new code and let me know your ideas. Thank you in advance.

Download All
0 Kudos
Message 5 of 22
(4,459 Views)

Thank you. BTW please look at the attached file. It is explained and the complete code.

0 Kudos
Message 6 of 22
(4,456 Views)
  • Your sequence structure has no purpose, delete it.
  • Decimal string to number would be more correct for intergers.
  • You can wire the "default" and change the datatype to get exactly the integer flavor you want, no need to convert later.
  • Read delimited spreadsheet would eliminate most code on the left. Set it to transpose and get the first row (i.e. first column after transposition) and you are almost there.
  • Your pyramid of case structures makes very little sense. The top and bottom array size never changes in the shift register, so why do you think you need to measure it with every iteration? What do you actually want to do? I am sure there is a solution that takes less than 10% of your code. 😄
0 Kudos
Message 7 of 22
(4,454 Views)
Solution
Accepted by Mmehrabin

@Mmehrabin wrote:

Please look at the new code and let me know your ideas. Thank you in advance.


  • You don't need the middle shift register, just use a conditional tunnel.
  • You don't need to chop up the top and bottom arrays. Operate in place and keep track of the current index.
  • The latency control belongs before the loop so it can be folded for the duration of the loop. I am sure it will (and should!) not change between two iterations, right.
  • Most of your boolean logic is baloney makes no sense. For example "=0 AND >0" will always be false!
  • Why is there a 2s delay in the loop? Just for debugging?
  • Are you sure the number wired to N is correct? I would think you a running out of elemens way before that.
0 Kudos
Message 8 of 22
(4,450 Views)

In each iteration, I remove an element from array1 and/or array2 so I should check their size.

0 Kudos
Message 9 of 22
(4,448 Views)

@Mmehrabin wrote:

In each iteration, I remove an element from array1 and/or array2 so I should check their size.


So why are you iterating NxM times? You'll probably run out of elements way before that.

Do you have a description or link for the algorithm you are trying to implement?

0 Kudos
Message 10 of 22
(4,440 Views)