Borrar filtros
Borrar filtros

how to set matrix from data

1 visualización (últimos 30 días)
yu yue
yu yue el 15 de Oct. de 2016
Comentada: Walter Roberson el 15 de Oct. de 2016
I have a path from node 6 to node 2, how can i can get the matrix like this [0 1 0 0 0 -1] ?

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Oct. de 2016
sn = 6; en = 2;
m = zeros(1, max(sn,en));
m(sn) = -1;
m(en) = 1;
  2 comentarios
yu yue
yu yue el 15 de Oct. de 2016
Editada: yu yue el 15 de Oct. de 2016
hi. If I have 6 node, but the path is from 3 to 5, how can I get [0 0 -1 0 1 0]? I only get [0 0 -1 0 1]
Walter Roberson
Walter Roberson el 15 de Oct. de 2016
m = zeros(1,6);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by