02-24-2012 12:57 PM
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
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.
Solved! Go to Solution.
02-24-2012 06:53 PM
Managed to somewhat solve second problem, any advice on the first one would be appreciated.
02-24-2012 08:05 PM
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.
02-25-2012 03:08 PM
Thanks, after some minor tweaking this was exactly what I was looking for