06-11-2010 11:06 AM
06-11-2010 11:22 AM - edited 06-11-2010 11:25 AM
What exactly is the problem?
I would use two nested loops, with something like matrix [i][j] = vector [i*10+j]
06-11-2010 11:29 AM
The probleme is that i want to transform a vector with values from a table (100 values), into a 10 x10 matrix array, with the following code
GetTableCellRangeVals (panelHandle, PANEL_TABLE, MakeRect(1,1,n,n), value_matrix, VAL_COLUMN_MAJOR);
for(i=1;i<=n-1; i++)
{for(j=1;j<=n-1; j++)
value_matrix[i]==matrix_1[i][j];}
Transpose (matrice_valori, n, n, matrice_transpusa);
for(i=1; i<=numar-1; i++)
{for(j=1;j<=numar-1; j++)
if(matrice_1[i][j]>=0)
{if(matrice_1[i][j]==matrice_transpusa[i][j])
SetCtrlVal (panelHandle, PANEL_LED, 1); }
Then I transpose the matrix, and compare it with the initial 10x10 matrix, and if all goes to plan. it should light up a LED.
But the probleme is that the vector does not copy itself into the matrix as it should, because my LED light up all the time. I can't seem to find the bug in these lines of code
06-11-2010 11:39 AM
I don't understand your code:
for(i=1;i<=n-1; i++)
{for(j=1;j<=n-1; j++)
value_matrix[i]==matrix_1[i][j];}
1) why does the index start at 1, not at zero?
2) the GetTable function returns value_matrix, why do you set new values using value_matrix == ? If you want to define your matrix, you will need to write matrix_1 [][] = ...
3) The matrix should be 10x10, in your case the indices i and j will run to 100?
06-11-2010 11:53 AM
1. It starts at 1 because the table i get my data from starts from row 1 column 1.
2. It got mixed arround, in the program; it actually is" matrix_1==value_matrix[i]". For some strange reason, allthough I have "Build with C99" turned on, i can't declare varible matrices ( matrix_1[n][m]), so the matrix is defined at it's maximum value matrix_1[10][10];
3.No, because the the table has variable numbers of rows and columns, i and j don't get past 10.The minimun is 2 and the maximum 10.
06-11-2010 12:01 PM - edited 06-11-2010 12:05 PM
ok... So did you check, using the Variable window, that your manually filled matrix is indeed filled with data as you want it to be?
You are transpoing different matrices than you are comparing later on...
06-11-2010 12:11 PM
06-11-2010 12:20 PM
I was asking for the correct matrix [][] because of your sentence
For me this means that the matrix is not as it should... ?
So, may be you also check the transposed matrix manually: the LED might not work as expected, e.g. if your routine is in a callback and no draw events are processed;
06-11-2010 12:32 PM
I've just noticed that this line of code is wrog, the one that takes the vector and puts it into the matrix
for(i=1;i<=numar-1; i++)
{for(j=1;j<=numar-1; j++)
matrix_1[i][j]==value_matrix[i];}
For the matrix, it reads all the elements, but for the vector, only half of them.
So back to my initial question.... how do you transform a vector into a matrix? in my case, a 100 value vector, into a 10x10 matrix.
06-11-2010 12:43 PM
are you referring to the vector you decided to call value_matrix?
Sorry, but I am still confused:
when I was asking if you checked your matrix_1 you said that that the input is ok.
How can it be ok (you need 10x10 values) if you read in only half of your vector, i.e. 50 elements...? I am giving up...