Re: How to insert a row to a matrix rapidly
- From: ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx (Roger Stafford)
- Date: Sun, 09 Oct 2005 05:24:31 GMT
In article <1128823613.635149.180040@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, "fl"
<rxjwg98@xxxxxxxxx> wrote:
> Hi,
> We know that it is to eliminate a row (or a column) by []. For example,
>
> a = [0:9].';
> b = reshape(a, 5, 2);
> b(2, :) = []
>
> b =
>
> 0 5
> 2 7
> 3 8
> 4 9
>
> Now, I want to insert one row of [1, 1] to the eliminated position.
> That is:
>
> b =
>
> 0 5
> 1 1
> 2 7
> 3 8
> 4 9
>
> Although I can copy the three rows first, then I insert one row [1, 1]
> and copy back the last three rows, I don't like that way. How to do
> this more efficiently?
>
> Thank you.
--------------------
Hello,
This is as efficient a method as I know for inserting [1 1] at the
second row of b:
b = [b(1,:);[1 1];b(2:end,:)]
(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford
.
- References:
- Prev by Date: Resampling image
- Next by Date: How to run the function of "armax" faster?
- Previous by thread: How to insert a row to a matrix rapidly
- Next by thread: Re: How to insert a row to a matrix rapidly
- Index(es):
Relevant Pages
|