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:
replace elements in matrix

Subject: replace elements in matrix

From: Dave B

Date: 2 Aug, 2012 14:28:08

Message: 1 of 3

If I have a matrix of zeros (size 100x100) and a matrix listing coordinates (row,col) of size 100x2. How do I replace elements of the 1st matrix specified by the 2nd matrix coords?

e.g. matrix1(matrix2)=1

thanks!

Subject: replace elements in matrix

From: Matt J

Date: 2 Aug, 2012 14:58:15

Message: 2 of 3

"Dave B" wrote in message <jve2po$4b8$1@newscl01ah.mathworks.com>...
> If I have a matrix of zeros (size 100x100) and a matrix listing coordinates (row,col) of size 100x2. How do I replace elements of the 1st matrix specified by the 2nd matrix coords?
>
> e.g. matrix1(matrix2)=1
===============

Use the SUB2IND command to convert your (row,col) coordinates in matrix 2 to linear indices.

Subject: replace elements in matrix

From: Dave B

Date: 2 Aug, 2012 15:23:10

Message: 3 of 3

"Matt J" wrote in message <jve4i7$bem$1@newscl01ah.mathworks.com>...
> "Dave B" wrote in message <jve2po$4b8$1@newscl01ah.mathworks.com>...
> > If I have a matrix of zeros (size 100x100) and a matrix listing coordinates (row,col) of size 100x2. How do I replace elements of the 1st matrix specified by the 2nd matrix coords?
> >
> > e.g. matrix1(matrix2)=1
> ===============
>
> Use the SUB2IND command to convert your (row,col) coordinates in matrix 2 to linear indices.

thanks a lot

Tags for this Thread

No tags are associated with 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