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:
Matrix

Subject: Matrix

From: Twilighter

Date: 8 Jul, 2011 20:12:10

Message: 1 of 3

i have a matrix like

X = ones(9,500);

i need to this operation

rows 1,3,7,9 i need to divide them by 0.5

row 5 will be the same no change

row 2,4,6,8 i need to divide them by 0.2

how can i do this in expression?

Subject: Matrix

From: Roger Stafford

Date: 8 Jul, 2011 20:22:09

Message: 2 of 3

"Twilighter " <mscmatlab@gmail.com> wrote in message <iv7oaq$d0r$1@newscl01ah.mathworks.com>...
> i have a matrix like
>
> X = ones(9,500);
>
> i need to this operation
>
> rows 1,3,7,9 i need to divide them by 0.5
>
> row 5 will be the same no change
>
> row 2,4,6,8 i need to divide them by 0.2
>
> how can i do this in expression?
- - - - - - - - - - -
 Y = bsxfun(@rdivide,X,[.5;.2;.5;.2;1;.2;.5;.2;.5]);

Roger Stafford

Subject: Matrix

From: Twilighter

Date: 8 Jul, 2011 20:56:09

Message: 3 of 3

thank you :)

"Roger Stafford" wrote in message <iv7oth$eem$1@newscl01ah.mathworks.com>...
> "Twilighter " <mscmatlab@gmail.com> wrote in message <iv7oaq$d0r$1@newscl01ah.mathworks.com>...
> > i have a matrix like
> >
> > X = ones(9,500);
> >
> > i need to this operation
> >
> > rows 1,3,7,9 i need to divide them by 0.5
> >
> > row 5 will be the same no change
> >
> > row 2,4,6,8 i need to divide them by 0.2
> >
> > how can i do this in expression?
> - - - - - - - - - - -
> Y = bsxfun(@rdivide,X,[.5;.2;.5;.2;1;.2;.5;.2;.5]);
>
> 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