Use a nx2 matrix to indicate desired positions on another matrix

1 visualización (últimos 30 días)
Hello everyone,
I have a quick question, how can i use the matrix lets say
pos = [1 2; 3 3];
as a guide to change the values of another matrix lets say
val = zeros(3);
avoiding for loops. What i want is something like var(pos(1,end,:)) = "some value"

Respuesta aceptada

Matt J
Matt J el 31 de Oct. de 2012
var(sub2ind(size(var), pos(:,1), pos(:,2))) = newvalue;

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by