How can I relate points of different matrices ?

2 visualizaciones (últimos 30 días)
Felipe
Felipe el 23 de Mayo de 2014
Comentada: arich82 el 23 de Mayo de 2014
matrix a,b and c size are (26,26) and i wanna relate points a(1,1) with b(1,1) and c(1,1) in a way that if i change the order of the points the point of matrix c matches with points of a and b.

Respuesta aceptada

Mahdi
Mahdi el 23 de Mayo de 2014
If you know exactly what you want to switch, follow this example:
A=[1 1; 2 2; 3 3]
And you want to switch row 1 with row 3, you would use
A([1 3],:)=A([3 1],:)
And you can repeat the same operation for the other matrices.
  1 comentario
arich82
arich82 el 23 de Mayo de 2014
Since you've already accepted, I'll just post this as a comment:
Depending on your application, it might make sense to store abc as a 26-by-26-by-3 array:
a = [11, 12; 21, 22; 31, 32];
b = a*10;
c = a*100;
abc = cat(3, a, b, c);
% swap, e.g., (1, 1) with (3, 1)
swap = abc(1, 1, :);
abc(1, 1, :) = abc(3, 2, :);
abc(3, 2, :) = swap;
Alternatively, you could create an object/classdef with a, b & c as members, and write a method such that whenever one updates the order, the others are synched, but that maybe more trouble than it's worth. A slightly simpler version would be to define a short function which takes in the three matrices and repeats the operation for you.
Ultimately, simply repeating the operation as Mahdi described might be easiest.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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