Removing a Row or Column From a Matrix

Removing a Row or Column From a Matrix - How to remove a row or column from a matrix while keeping all assigned units to elements in the matr - Mensajes

#1 Publicado: 21/9/2022 15:40:35
Ryan Freund

Ryan Freund

20 me gusta en 339 mensajes.

Grupo: User

How can I remove a row or column from a matrix while keeping all assigned units to the elements in the matrix.

For example let's say that I have a matrix with the first column containing all text, the next column contains numbers with units of inches, and the next column has units of pounds. I want to create a new matrix but I want the entire 3rd row removed. I also want to keep the appearance of the units (i.e. text, inches, lbs).
Is this possible?

Thanks!
#2 Publicado: 21/9/2022 19:21:22
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

Wrote

How can I remove a row or column from a matrix while keeping all assigned units to the elements in the matrix.


Well you can't show it with conventional ways if it contains string column.
I am not sure if it is possible when a string column is absent if it has mixed units.
However, you can use a table region to show your new matrix.
Not an ideal solution, but it is what we can have.

Regards

2022-09-22_01-20.png
#3 Publicado: 22/9/2022 7:02:40
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: Moderator

Something like this?

rmRows_rmCols.sm (35,17 KiB) descargado 1349 vez(es).
2022-09-22 12_01_13-SMath Solver - [rmRows_rmCols.sm].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Publicado: 22/9/2022 11:16:00
sergio

sergio

127 me gusta en 342 mensajes.

Grupo: User

I believe that rfreund wanted to keep the units of measurement set. I take Davide's solution and I add a trick (I think he had been offered by Overlord or Razonar or perhaps from both).
However, I still have to solve for the strings. Furthermore, if we cancel the columns instead of the lines we should build the units of measurement of the matrix resulting with the same method.
rmRows_rmCols_units.sm (15,7 KiB) descargado 1292 vez(es).
sergio
A 1 usuarios les gustó este mensaje
Ryan Freund 14/11/2022 18:24:00
#5 Publicado: 22/9/2022 19:14:03
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

Wrote

I believe that rfreund wanted to keep the units of measurement set. I take Davide's solution and I add a trick (I think he had been offered by Overlord or Razonar or perhaps from both).
However, I still have to solve for the strings. Furthermore, if we cancel the columns instead of the lines we should build the units of measurement of the matrix resulting with the same method.


I first see usage of diag() for units by Razonar, then just wrote it as in your example.
Another way is using pseudo units, but this is also not interchangeable.
Again, these are not conventional ways. Just holding your left ear with your right hand.
And there is no solution for string column I guess.

Regards

matrix mixed units.sm (9 KiB) descargado 1279 vez(es).

2022-09-23_00-39.png
#6 Publicado: 23/9/2022 4:26:49
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

One might use vector-valued indices.

rmRows_rmCols_Kr.sm (7,87 KiB) descargado 1300 vez(es).
rmRows_rmCols_Kr.png
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#7 Publicado: 23/9/2022 8:55:30
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

All you missing some points of Rfreund's question, except Sergio.
He asked for a string column, an inch column and a pound column.
And showing result matrix as written. This is the tricky part.
Not removing rows of an ordinary matrix with SI units.
He specifically asked removing a row of mixed non-SI units matrix.
And displaying it with non-SI units.
#8 Publicado: 23/9/2022 10:32:58
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

Wrote

That will reduce the fractal replies.


It is clear what Rfreund has asked, no need to upload an smath file.
Take this matrix, remove its third row, make it look like as intended.
With its string and non-SI columns displayed as they are.

2022-09-23_16-32.png
#9 Publicado: 24/9/2022 5:56:56
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Wrote

All you missing some points of Rfreund's question, except Sergio.
He asked for a string column, an inch column and a pound column.
And showing result matrix as written. This is the tricky part.
Not removing rows of an ordinary matrix with SI units.
He specifically asked removing a row of mixed non-SI units matrix.
And displaying it with non-SI units.



So the topic is "display of matrices in non-default units". No idea if the presence of strings is relevant for the problem.

This question is another vote for a function defaultUnit(u).

This function would be inserted wherever appropriate in a document.

An option to set the default units by document or system-wide in the units dialog would be helpful. Otherwise, we will see many documents starting with blocks of unit settings. Yet, still the above-mentioned function would be required, because at different places in a document you might need different settings.

units6.png

Of course, if you want to mix different units of the same quantity, then setting the default unit would not help either.
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#10 Publicado: 24/9/2022 7:56:57
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

Wrote

No idea if the presence of strings is relevant for the problem.


This is how it is relevant, somehow you can view your matrix with method I have showed.
But if matrix contains a string column, the sample below won't work too.
That's what Rfreund asked I guess, string and mixed units columns viewing.

Regards

2022-09-24_13-53.png
A 1 usuarios les gustó este mensaje
Ryan Freund 14/11/2022 14:50:00
#11 Publicado: 24/9/2022 9:34:28
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

MixedUnits.PNG
A 1 usuarios les gustó este mensaje
Ryan Freund 14/11/2022 14:50:00
#12 Publicado: 24/9/2022 18:20:23
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Wrote

Wrote

No idea if the presence of strings is relevant for the problem.


This is how it is relevant, somehow you can view your matrix with method I have showed.
But if matrix contains a string column, the sample below won't work too.
That's what Rfreund asked I guess, string and mixed units columns viewing.

Regards



Thanks for clarification. Perhaps overloading the multiply operator to strings could help then, but that is probably too far-fetched. 1*"a"="a", 2*"a"="aa".
For now I just stick with displaying individual columns with custom units instead of whole matrices or in rare cases I use tables.
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
A 1 usuarios les gustó este mensaje
Ryan Freund 14/11/2022 14:50:00
#13 Publicado: 25/9/2022 2:47:33
Laurent Fournier

Laurent Fournier

9 me gusta en 66 mensajes.

Grupo: User

Fascinating catalog of examples!
Thanks to all!
That all these neat and concise writings are possible really show how brilliant Smath is as a software!
#14 Publicado: 14/11/2022 14:49:45
Ryan Freund

Ryan Freund

20 me gusta en 339 mensajes.

Grupo: User

Thanks for all your efforts on this. Very impressive!

Also sorry for being ambiguous. My question really was twofold - First, can I simply remove a row or column and keep the assigned units. Second, can we do this with Text. Seems as though the answer is yes and no. Yes, you can remove the row or column, but no you cannot get it to display in non-SI units.

The table idea isn't bad, but I really like having more control over what units are displayed or are considered default.

Thanks again.
#15 Publicado: 16/11/2022 8:51:17
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

Yes, you can remove the row or column, but no you cannot get it to display in non-SI units.


Smath is delivered with silent units or active SI ...
... silent units as required

Page4 Delete Col-Row.sm (15,27 KiB) descargado 1424 vez(es).
#16 Publicado: 16/11/2022 23:04:59
Ryan Freund

Ryan Freund

20 me gusta en 339 mensajes.

Grupo: User

Martin - I didn't realize that you could use "vector-valued indices" to reorganize matrices. That might be useful to me in the future. Although I suppose using the submatrix function is pretty similar.

Jean - it took me a minute to understand "silent-units" as I thought the apostrophe in front of the unit solved the unit "display" issue. I guess it does if you only want it to "look correct". Thanks for your efforts.
#17 Publicado: 17/11/2022 8:20:36
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Wrote

Martin - I didn't realize that you could use "vector-valued indices" to reorganize matrices. That might be useful to me in the future. Although I suppose using the submatrix function is pretty similar.



The index vector approach is more flexible, as it allows to pick arbitrary subsets of rows and columns instead of continuous ranges.

iv.sm (4,1 KiB) descargado 1281 vez(es).
iv.png
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#18 Publicado: 17/11/2022 11:38:10
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

Jean - it took me a minute to understand "silent-units" as I thought the apostrophe in front of the unit solved the unit "display" issue. I guess it does if you only want it to "look correct". Thanks for your efforts.


Silent mode disables the SI unit sub-processor.
Don't miss visiting this great matrix shuffling utility.
Cheers ... Jean.

Utilities Matrix Shuffle.sm (12,31 KiB) descargado 1288 vez(es).

#19 Publicado: 17/11/2022 11:50:17
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

... this clean version.

Utilities Matrix Shuffle.sm (14,73 KiB) descargado 1325 vez(es).
#20 Publicado: 18/11/2022 0:59:14
Ryan Freund

Ryan Freund

20 me gusta en 339 mensajes.

Grupo: User

@Martin - Good point. I still don't know how I will use this feature, but I already see it being a little more difficult to use in some sort of function. Just seems like it lends itself to manual creation of the vector used in the indices, but I suppose you just need to be creative enough.
  • Nuevos mensajes
  • Sin mensajes nuevos