Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
vectorizing code

Subject: vectorizing code

From: Jehad Zughyer

Date: 21 Dec, 2008 22:25:04

Message: 1 of 2

Can this code be vectorized?

for i=1:50;
m1tom3(i)=poissrnd(8);
m2tom1(i)=poissrnd(24);
m2tom3(i)=poissrnd(20);
m3tom1(i)=poissrnd(15);
m3tom2(i)=poissrnd(14);
end

Subject: vectorizing code

From: Roger Stafford

Date: 21 Dec, 2008 23:26:02

Message: 2 of 2

"Jehad Zughyer" <zjehad@yahoo.com> wrote in message <gimfo0$161$1@fred.mathworks.com>...
> Can this code be vectorized?
>
> for i=1:50;
> m1tom3(i)=poissrnd(8);
> m2tom1(i)=poissrnd(24);
> m2tom3(i)=poissrnd(20);
> m3tom1(i)=poissrnd(15);
> m3tom2(i)=poissrnd(14);
> end

  I would suggest you carefully read the documentation for 'poissrnd'. It seems pretty clear to me how to vectorize it. Just use its second and third input arguments appropriately.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us