11-10-2016 05:12 PM - edited 11-10-2016 05:15 PM
I tried to add the elements from the main diagonal with this code ( replace < with = ) and it works...If I use < or > the code won't work and I saw that it depends which element from the index ( inside the second for ) I add .Can someone explain me why it depends which element I add ? Why are there 2 elements in the first place and not one element with the i,j coordinates ?
I want an answer for this solution,I'm not interested in other much simpler solutions.
How can I make THIS code easier ?
Solved! Go to Solution.
11-10-2016 05:25 PM - edited 11-10-2016 05:43 PM
Regarding your problem, try some debugging steps, for example place some probes or use execution highlighting. Slow down the loops and add extra indicators, etc.
Since you are autoindexing on the outer loop, you only have a 1D array inside the inner loop and you are indexing out two neighbors. If you would disable indexing on the outer loop input, you'll get a 2D array and can get a single element based on the two indices. Do some tutorials!
11-10-2016 05:39 PM - edited 11-10-2016 05:39 PM
@dafuq313 wrote:
I want an answer for this solution,I'm not interested in other much simpler solutions.
@dafuq313 wrote:
How can I make THIS code easier ?
You are contradicting yourself. Easier is always simpler. The explanation is at the end of my previous post. You need to understand autoindexing and arrays. Once you understand it, the code boils down to this.
11-10-2016 06:01 PM - edited 11-11-2016 12:49 AM
@dafuq313 wrote:I want an answer for this solution,I'm not interested in other much simpler solutions.
Here's how to program your solution correctly. (of course since the matrix is always square, we only need to get one of the dimensions...)
11-11-2016 02:43 PM
Thank you for answers,I was trying to say that there are easier solutions ( withouth 2 fors ) and I didn't want one of those.
I couldn't find proper tutorials for labview since is not that much used...
Thank you very much 😄
11-11-2016 09:36 PM - edited 11-11-2016 09:36 PM
Even my simple solution has two FOR loops. 🙂