Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Writing 2 vectors within matrix

1 vue (au cours des 30 derniers jours)
Miguel Cardoso
Miguel Cardoso le 19 Fév 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi!
I have 2 vectores I where are written the indexes of a matrix M and J which are the values that I want to write on matrix M. Bellow I give a generic example, how can I do it automatically?
I=[1 1 1 2 2 2 3 3 3];
J=[2 4 7 3 1 4 9 6 4];
M=[2 4 7; 3 1 4; 9 6 4];
Hope you can help me!

Réponses (1)

fred  ssemwogerere
fred ssemwogerere le 19 Fév 2020
Hello, use reshape
M=reshape(J,[3,3])';
  1 commentaire
Miguel Cardoso
Miguel Cardoso le 19 Fév 2020
Thank you!

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by