How can I relate points of different matrices ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Mahdi
le 23 Mai 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 commentaire
arich82
le 23 Mai 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!