Sign in

username or email:

password:



Not a member?
Forgot your password?

Search matlab



Search tips

Subscribe to matlab



Ads

Discussion Groups

See Also

Embedded SystemsFPGA

Discussion Groups | Matlab DSP | Adding Rows to a Matrix

Hi Could somebody please help. Inside a loop I generate a (1X5)vector. At each step I want to include this vector as a new row of a matrix...

  

Post a new Thread



Is this thread worth a thumbs up?

0

Adding Rows to a Matrix - camdmag - Apr 14 12:42:00 2005



Hi

Could somebody please help.

Inside a loop I generate a (1X5)vector. At each step I want to
include this vector as a new row of a matrix. So, for example, after
10 times through the loop I will have generated a (10X5) matrix.

Is there a quick way of doing this?

Any help would be much appreciated.

Thanks

Cal



______________________________
New Code Sharing Section now Live on DSPRelated.com. Learn about the Reward Program for Contributors here.



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Adding Rows to a Matrix - V Ravi Chander - Apr 15 9:41:00 2005


hi cal,
if 'b' is the 1X5 vector generated inside the for loop, and 'a' is the
10X5 matrix that you need,

for i=1:10
%some processing to obtain b
a(i,:)=b;
%or a=[a;b];
end

regards,
Ravi > Hi
>
> Could somebody please help.
>
> Inside a loop I generate a (1X5)vector. At each step I want to
> include this vector as a new row of a matrix. So, for example, after
> 10 times through the loop I will have generated a (10X5) matrix.
>
> Is there a quick way of doing this?
>
> Any help would be much appreciated.
>
> Thanks
>
> Cal --
V Ravi Chander,
Emerging Technologies and Services Group,
Reliance Infocomm Ltd.






(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Adding Rows to a Matrix - dutmatlab - Apr 16 5:18:00 2005


Hi,

two solutions :

A=[];
for n=1:10
A=[A rand(1,5)];
end

or

A=zeros(10,5);
for n=1:10
A(n,:)=rand(1,5);
end

The second one should be faster because matrix A is pre-alocated.

Jérôme






(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )