I wanted to know this to solve a problem I had. But now the problem was solved on an other way, so I don't need to know this anymore. Thanks everyone for helping!
'rotating' matrix data around one point
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone,
I am having the following matrix:
-0.0052 -0.0113 -0.0178 -0.0157 -0.0053 0.0033 0.0073 0.0080 0.0071
-0.0032 -0.0152 -0.0433 -0.0370 -0.0014 0.0144 0.0173 0.0150 0.0114
0.0062 0.0026 -0.1158 -0.0565 0.0423 0.0467 0.0380 0.0267 0.0173
0.0205 0.0551 0.2696 0.3313 0.1654 0.1145 0.0758 0.0435 0.0237
0.0268 0.0611 0.1415 0.2187 0.2313 0.2187 0.1415 0.0611 0.0268
0.0237 0.0435 0.0758 0.1145 0.1654 0.3313 *0.2696* 0.0551 0.0205
0.0173 0.0267 0.0380 0.0467 0.0423 -0.0565 *-0.1158* 0.0026 0.0062
0.0114 0.0150 0.0173 0.0144 -0.0014 -0.0370 -0.0433 -0.0152 -0.0032
0.0071 0.0080 0.0073 0.0033 -0.0053 -0.0157 -0.0178 -0.0113 -0.0052
Now I want the data to 'move' around one of the 'points' in the matrix, namely the one between the marked points (0.2696 and -0.01158). So I want to -0.0433 point to be in the place of the -0.0370 point and the -0.0370 point one the place of the -0.0565 point and so on. I have no idea how to do this. Hopefully one of you will know.
Thanks in advance
採用された回答
Andrei Bobrov
2014 年 3 月 17 日
編集済み: Andrei Bobrov
2014 年 3 月 17 日
data = [ -0.0052000 -0.0113000 -0.0178000 -0.0157000 -0.0053000 0.0033000 0.0073000 0.0080000 0.0071000
-0.0032000 -0.0152000 -0.0433000 -0.0370000 -0.0014000 0.0144000 0.0173000 0.0150000 0.0114000
0.0062000 0.0026000 -0.1158000 -0.0565000 0.0423000 0.0467000 0.0380000 0.0267000 0.0173000
0.0205000 0.0551000 0.2696000 0.3313000 0.1654000 0.1145000 0.0758000 0.0435000 0.0237000
0.0268000 0.0611000 0.1415000 0.2187000 0.2313000 0.2187000 0.1415000 0.0611000 0.0268000
0.0237000 0.0435000 0.0758000 0.1145000 0.1654000 0.3313000 0.2696000 0.0551000 0.0205000
0.0173000 0.0267000 0.0380000 0.0467000 0.0423000 -0.0565000 -0.1158000 0.0026000 0.0062000
0.0114000 0.0150000 0.0173000 0.0144000 -0.0014000 -0.0370000 -0.0433000 -0.0152000 -0.0032000
0.0071000 0.0080000 0.0073000 0.0033000 -0.0053000 -0.0157000 -0.0178000 -0.0113000 -0.0052000];
s = size(data);
ii = [6 7]; % index rows
jj = [7 7]; % index of columns
z = zeros(s);
z(sub2ind(s,ii,jj)) = 1;
t = 0 + (bwdist(z,'ch') == 1);
boundaries = bwboundaries(t,8);
b = boundaries{1}(1:end-1,:);
b1 = b*[1; s(1)] - s(1);
out = data;
out(b1) = out(circshift(b1,1));
その他の回答 (1 件)
Jos (10584)
2014 年 3 月 17 日
You can use CIRCSHIFT to move the a point to the centre of the matrix, and then apply ROT90 to rotate it, and apply CIRCSHIFT again.
M1 = magic(5)
rotpos = [0 1] % position of rotation point
M2 = circshift(M1,-rotpos)
M3 = rot90(M2)
M4 = circshift(M3, rotpos)
I am not sure if this is what you're really after though ...
参考
カテゴリ
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!