Azzera filtri
Azzera filtri

How can I relate points of different matrices ?

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Mahdi
Mahdi il 23 Mag 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 Commento
arich82
arich82 il 23 Mag 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by