How to add rows to matrix by condition

How to add rows to matrix by condition - Сообщения

#1 Опубликовано: 25.02.2021 05:11:56
Yuri Feoktistov

Yuri Feoktistov

0 сообщений из 8 понравились пользователям.

Группа: User

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.
#2 Опубликовано: 25.02.2021 07:55:32
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: Moderator

That's a rough implementation, although I probably misunderstood some part.

2021-02-25 11_53_19-SMath Studio - [Page1_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
Yuri Feoktistov 25.02.2021 11:21:00
#3 Опубликовано: 25.02.2021 08:06:24
Yuri Feoktistov

Yuri Feoktistov

0 сообщений из 8 понравились пользователям.

Группа: User

It should be something like this but probably there is a better decision
#4 Опубликовано: 25.02.2021 09:10:01
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: Moderator

Seems I missed the physical meaning, this should be a better implementation:

2021-02-25 13_13_59-SMath Studio - [split layers.sm].png

split layers.sm (10 КиБ) скачан 35 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
Yuri Feoktistov 25.02.2021 11:21:00
#5 Опубликовано: 25.02.2021 10:24:29
Yuri Feoktistov

Yuri Feoktistov

0 сообщений из 8 понравились пользователям.

Группа: User

It is magic! Thank you!
Can you do the same whith distance units?
#6 Опубликовано: 25.02.2021 11:42:14
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: Moderator

Wrote

It 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)


2021-02-25 15_37_39-SMath Studio - [split layers.sm_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 пользователям понравился этот пост
sergio 25.02.2021 13:31:00, Yuri Feoktistov 26.02.2021 03:15:00
#7 Опубликовано: 25.03.2021 07:43:03
RichardSmith

RichardSmith

0 сообщений из 2 понравились пользователям.

Группа: User

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!
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений