Community Tip - You can change your system assigned username to something more personal in your community settings. X
Neptali Barte wrote:
Yes, it works! Thanks Raiko. My another problem is that when I add more values in the columns of the 1st row only (See snapshot). It only gets the first row only. I want to include in the results the values of the second to the last row where there is a value even when there are zeroes below the 1st row.
Change your last line to
submatrix(test,min(I),max(I),min(J),max(J))
Stuart
Use submatirx()
Yup, the answer is quite correct but my goal is that, I don't want to update or change the value inside the submatrix function everytime I add values to either the rows or colums of "test" table. "test" is actually an excel component that I made with an output range say A1:F100. Anytime, I want to add values in the rows and columns in ascending order, the remaining cells in the range will be zero. An I only wanted to get the values in the cells that have an input in excel component. Do somebody have a function to do this?
Hello Neptali,
this function does the trick. However, if the pattern of the non-zero values is irregular (e.g. interspersed with zeros) it will generate an array that still contains some zeros.
Raiko
I'm using an excel component for the table and I got the below error in red. Why?
Neptali Barte wrote:
I'm using an excel component for the table and I got the below error in red. Why?
Because you have i counting columns instead of rows (and j counting rows instead of columns). the index test[i,j identifies row i, column j. Change them round and swap q and p in your submatrix call.
Stuart
PS,
a. There is no need to add the <>0 test after the IsString call; Mathcad treats all non-zero values as true and as IsString evaluates to 1 for a string, then it will be (by definition) not equal to zero. I don't think you need the test anyway, all you're after is non-zero elements and a string is <> 0.
b. There is no need to assign the result of submatrix to W; it's redundant as you don't use W and Mathcad will simply return the value of the submatrix if you remove the W<- bit.
Hello Stuart,
thanks for the remarks. You're right, some of the code is redundant.
Raiko
P.S.
Neptali, does the function work now?
Yes, it works! Thanks Raiko. My another problem is that when I add more values in the columns of the 1st row only (See snapshot). It only gets the first row only. I want to include in the results the values of the second to the last row where there is a value even when there are zeroes below the 1st row.
Neptali Barte wrote:
Yes, it works! Thanks Raiko. My another problem is that when I add more values in the columns of the 1st row only (See snapshot). It only gets the first row only. I want to include in the results the values of the second to the last row where there is a value even when there are zeroes below the 1st row.
Change your last line to
submatrix(test,min(I),max(I),min(J),max(J))
Stuart