SMath Studio Forum
»
SMath Studio
»
Questions
»
How to add rows to matrix by condition
![babalus babalus](/forum/images/noavatar.gif) Rank: Newbie
Groups: Registered
Joined: 10/02/2018(UTC) Posts: 3 ![Russian Federation Russian Federation](/forum/Content/images/flags/RU.png)
|
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.
|
|
|
|
![Davide Carpi Davide Carpi](/forum/resource.ashx?u=1544) ![](/forum/Images/Ranks/Advanced-Member.png) Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 ![Man Man](/forum/Themes/yafvision/male.gif) ![Italy Italy](/forum/Content/images/flags/IT.png) Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
That's a rough implementation, although I probably misunderstood some part. ![2021-02-25 11_53_19-SMath Studio - [Page1_].png](/forum/resource.ashx?a=36839&b=2) |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
![thanks](/forum/Themes/yafvision/heart_small.png) 1 user thanked Davide Carpi for this useful post.
|
|
|
![babalus babalus](/forum/images/noavatar.gif) Rank: Newbie
Groups: Registered
Joined: 10/02/2018(UTC) Posts: 3 ![Russian Federation Russian Federation](/forum/Content/images/flags/RU.png)
|
It should be something like this but probably there is a better decision
|
|
|
|
![Davide Carpi Davide Carpi](/forum/resource.ashx?u=1544) ![](/forum/Images/Ranks/Advanced-Member.png) Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 ![Man Man](/forum/Themes/yafvision/male.gif) ![Italy Italy](/forum/Content/images/flags/IT.png) Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
Seems I missed the physical meaning, this should be a better implementation: ![2021-02-25 13_13_59-SMath Studio - [split layers.sm].png](/forum/resource.ashx?a=36842&b=2) split layers.sm (11kb) downloaded 15 time(s).Edited by user 25 February 2021 15:14:47(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
![thanks](/forum/Themes/yafvision/heart_small.png) 1 user thanked Davide Carpi for this useful post.
|
|
|
![babalus babalus](/forum/images/noavatar.gif) Rank: Newbie
Groups: Registered
Joined: 10/02/2018(UTC) Posts: 3 ![Russian Federation Russian Federation](/forum/Content/images/flags/RU.png)
|
|
|
|
|
![Davide Carpi Davide Carpi](/forum/resource.ashx?u=1544) ![](/forum/Images/Ranks/Advanced-Member.png) Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 ![Man Man](/forum/Themes/yafvision/male.gif) ![Italy Italy](/forum/Content/images/flags/IT.png) Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
Originally Posted by: babalus ![Go to Quoted Post Go to Quoted Post](/forum/Themes/yafvision/icon_latest_reply.gif) 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](/forum/resource.ashx?a=36845&b=2) Edited by user 25 February 2021 19:01:24(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
![thanks](/forum/Themes/yafvision/heart_small.png) 2 users thanked Davide Carpi for this useful post.
|
on 25/02/2021(UTC), on 26/02/2021(UTC)
|
|
![Richard Smith Richard Smith](/forum/images/noavatar.gif) Rank: Newbie
Groups: Registered
Joined: 25/03/2021(UTC) Posts: 2 ![United States United States](/forum/Content/images/flags/US.png) Location: Los Angeles
|
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! Edited by user 25 March 2021 13:45:05(UTC)
| Reason: Emoticons
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
How to add rows to matrix by condition
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.