How can I relate points of different matrices ?

2 views (last 30 days)
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.

Accepted Answer

Mahdi
Mahdi on 23 May 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 Comment
arich82
arich82 on 23 May 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!