Re: Row inserting



"John Brown" <johnbrown@xxxxxxxxx> wrote in message
news:ef27478.-1@xxxxxxxxxxxxxxxxxxx
> Hi,
> I am looking for a matlab function to insert a new row to an existing
> matrix. Can anyone help me?
> Thanks...

Okay... I'll bite, though I'm sure there are better ways than this.

>> a = randn(7)

a =

-0.0592 0.3803 -1.8740 0.5689 0.3148 0.2120 0.0880
-1.0106 -1.0091 0.4282 -0.2556 1.4435 0.2379 -0.6355
0.6145 -0.0195 0.8956 -0.3775 -0.3510 -1.0078 -0.5596
0.5077 -0.0482 0.7310 -0.2959 0.6232 -0.7420 0.4437
1.6924 0.0000 0.5779 -1.4751 0.7990 1.0823 -0.9499
0.5913 -0.3179 0.0403 -0.2340 0.9409 -0.1315 0.7812
-0.6436 1.0950 0.6771 0.1184 -0.9921 0.3899 0.5690

>> i = 5

i =

5

>> b = ones(1, 7)

b =

1 1 1 1 1 1 1

>> a = [a(1:i,:); b; a(i+1:end, :)]

a =

-0.0592 0.3803 -1.8740 0.5689 0.3148 0.2120 0.0880
-1.0106 -1.0091 0.4282 -0.2556 1.4435 0.2379 -0.6355
0.6145 -0.0195 0.8956 -0.3775 -0.3510 -1.0078 -0.5596
0.5077 -0.0482 0.7310 -0.2959 0.6232 -0.7420 0.4437
1.6924 0.0000 0.5779 -1.4751 0.7990 1.0823 -0.9499
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
0.5913 -0.3179 0.0403 -0.2340 0.9409 -0.1315 0.7812
-0.6436 1.0950 0.6771 0.1184 -0.9921 0.3899 0.5690


.



Relevant Pages

  • Re: Software advice
    ... Okay, I'll bite. ... What sort of distortion would have been of any value? ... Prev by Date: ...
    (rec.arts.sf.fandom)
  • Re: If Iran had peaceful intentions
    ... Okay, I'll bite... ... who in the name of sweet bloody jehosaphat said ... Prev by Date: ...
    (rec.sport.football.college)
  • Re: Row inserting
    ... Ken Davis wrote: ... >> I am looking for a matlab function to insert a new row to an ... I'll bite, though I'm sure there are better ways than this. ... Prev by Date: ...
    (comp.soft-sys.matlab)
  • Re: Sorry ducks
    ... Just keep those duck jokes non-violent. ... Okay, a duck can bite the ass of ... Prev by Date: ...
    (rec.arts.theatre.musicals)
  • Re: Pretty much a self-Godwinizing post
    ... >> Matthew B. Tepper wrote: ... >>> place of business. ... >> Okay, I'll bite. ...
    (rec.arts.sf.fandom)