Skip to main content
14-Alexandrite
February 22, 2024
Solved

Using On Error

  • February 22, 2024
  • 3 replies
  • 2664 views

Dear forum,

Does anyone know what the error is and why it doesn't give the result I expect?

Regards,

CarlosRomero

Best answer by Werner_E

I don't understand why you expected a different result than the one you got!

The function does exactly what its name suggests - it deletes all COLUMNS in a matrix which consist of all zeros.

The function does not claim to deal with the rows, so rows with all-zero values remain intact.

 

To remove the all-zero rows as well you need a function trimZeroRows( ). But you don't have to write that function, simply use trimZeroCols on the transposed matrix and then transpose the result.

Werner_E_2-1708628319060.png

 

So you can also easily create a trimZeroRowsandCols( ) function in one line:

Werner_E_1-1708628265681.png

 

BTW, here is an alternative trimZeroCols( ) function which does not make use of my Is Element( ) function

Werner_E_3-1708628932754.png

 

 

 

3 replies

20-Turquoise
February 22, 2024

  Hello, CarlosRomero

  It seems to be :

1.PNG2.PNG

3.PNG

   Best Regards.

       Loi.

Werner_E25-Diamond IAnswer
25-Diamond I
February 22, 2024

I don't understand why you expected a different result than the one you got!

The function does exactly what its name suggests - it deletes all COLUMNS in a matrix which consist of all zeros.

The function does not claim to deal with the rows, so rows with all-zero values remain intact.

 

To remove the all-zero rows as well you need a function trimZeroRows( ). But you don't have to write that function, simply use trimZeroCols on the transposed matrix and then transpose the result.

Werner_E_2-1708628319060.png

 

So you can also easily create a trimZeroRowsandCols( ) function in one line:

Werner_E_1-1708628265681.png

 

BTW, here is an alternative trimZeroCols( ) function which does not make use of my Is Element( ) function

Werner_E_3-1708628932754.png

 

 

 

14-Alexandrite
February 23, 2024

Thanks Loi and Werner.

A good solution Loi.

 

Werner, thanks for pointing out that to delete the rows it was only necessary to use the transposed trimZeroCols.

I attach your alternative function that does not use IsElement but returns an error?

 

Regards,

CarlosRomero

25-Diamond I
February 23, 2024

Uhh, that one was a bit tricky 😉

Right click at the bar after the sum symbol. The menu which pops up gives you (amongst others) the choice between "Absolute Value" and "Square Matrix Determinant". Check "Absolute Value" and the function works OK.

20-Turquoise
February 26, 2024

   Hi, again, CarlosRomero.

   So far, I guess your this question has NOT been solved with both of ORIGIN := 1 and ORIGIN := 0 !!! 🤔

   With :

1.PNG

      Regards.

         Loi.