How can I relate points of different matrices ?
2 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Mahdi
2014-5-23
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 个评论
arich82
2014-5-23
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!