1 Pages (7 items)
How to add rows to matrix by condition - Messages
#1 Posted: 2/25/2021 5:11:56 AM
If the value in the second column of the matrix is greater than the specified constant, then you need to replace the row containing this value by the number of rows equal to quotient of division of this number by constant + 1. In the first rows, the value in the second column must be equal to a constant, and in the last row the value in the second column must be equal to a remainder of the integer division of the number by a constant.
On the left is the original matrix, on the right is what should be obtained.
On the left is the original matrix, on the right is what should be obtained.
#3 Posted: 2/25/2021 8:06:24 AM
It should be something like this but probably there is a better decision
#4 Posted: 2/25/2021 9:10:01 AM
Seems I missed the physical meaning, this should be a better implementation:
![2021-02-25 13_13_59-SMath Studio - [split layers.sm].png](/en-US/file/TEK5Ar/2021-02-25-13_13_59-SMath-Studio---_split-layers_sm__png)
split layers.sm (10 KiB) downloaded 32 time(s).
split layers.sm (10 KiB) downloaded 32 time(s).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Yuri Feoktistov 2/25/2021 11:21:00 AM
#5 Posted: 2/25/2021 10:24:29 AM
It is magic! Thank you!
Can you do the same whith distance units?
Can you do the same whith distance units?
#6 Posted: 2/25/2021 11:42:14 AM
WroteIt is magic! Thank you!
Can you do the same whith distance units?
There's not much to change, just add the units to:
- threshold
- const
- rem, here you have to reintroduce the unit (automated by UnitsOf() or directly)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 users liked this post
#7 Posted: 3/25/2021 7:43:03 AM
Hint: You can get a submatrix like this:
subMatrix = fullMatrix(1:someRow, : );
subMatrix = fullMatrix(row1:row2, : );
subMatrix = fullMatrix(someRow:end, : ); % End has a special meaning
(pick one), and you can concatenate matrices vertically like this:
tallMatrix = [shortMatrix1; shortMatrix2]; % Use as many as you want
They all have to have the same number of columns of course.
I hope this helps, thanks!
subMatrix = fullMatrix(1:someRow, : );
subMatrix = fullMatrix(row1:row2, : );
subMatrix = fullMatrix(someRow:end, : ); % End has a special meaning
(pick one), and you can concatenate matrices vertically like this:
tallMatrix = [shortMatrix1; shortMatrix2]; % Use as many as you want
They all have to have the same number of columns of course.
I hope this helps, thanks!
1 Pages (7 items)
-
New Posts
-
No New Posts