LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem sorting arrays and... Using case feature

Solved!
Go to solution

Ok, so im doing this little code that solves linear 3x3 equations, I have most of the code made just missing 2 small bits for ascetics value, Ail try to describe them as detailed as I can, any type of advice or guidance with any of them would be greatly appreciated

 

Some Details of the program:

Equation MUST be ingress into a String, and should (and probably must) be able to do some hard fixing

It will be limited to +'s and -'s signs

 

 

Problem 1.

I don't really know how to "sort" my equation according to their variables, example:

User input:  -2 y   +1 *x -1 z = 2

What I can make it look like: -2 y + 1 x -1 z = 2

What I want it to look like: 1 x -2 y -1 z = 2 

 

I can manage to sort the equation, IF I knew the order the user is going to add the variables, the only thing that comes to my mind is turning them into an array and making one case for each ( x,y,z -- x,z,y -- etc) and using some sort of elimination process to choose the "shorter  or longer" array, I really haven't put much though into this because it seems like a dumb idea, but its the only thing It comes to my mind.

 

 

Problem 2.

So as im fixing the spaces between the characters, in the case I find a "10", I don't want a "1 0", I very roughly managed to get around this problem using a "Search and replace String", but I have problems making a "Case" for it, as in, I cant figure out the "right" input for a case string, example:

User input:  1 x -2 y -1 z = 12 

Untitled.jpg

The result inside the case is correct and looks like a "12", but as I don't know the correct input, obviously my default case is empty and it passes right through, so the result outside is a "1 2"

 

Any link for someone who fixed a similar problem or guides would be great, also Id like to announce that 3 weeks ago I did not even knew what was "LabVIEW", so if you can "dumb down" the explanations a bit would be greatly appreciated.

0 Kudos
Message 1 of 4
(2,177 Views)

Managed to somewhat solve second problem, any advice on the first one would be appreciated.

0 Kudos
Message 2 of 4
(2,146 Views)
Solution
Accepted by Mikado86

You could try to use the tokenizer to help parse it. The attached was a quickly hacked together solution that makes several assumptions (a big one being that the input is correct and the equal to is the last thing). So it's not really a complete solution.

 

Sorry I didn't have time to comment it. If it looks funny I was using the silver controls which got lost when I saved it for the previous version.

Message 3 of 4
(2,135 Views)

Thanks, after some minor tweaking this was exactly what I was looking for

0 Kudos
Message 4 of 4
(2,113 Views)