Correlate a 3d array into n times 2d rows
3 次查看(过去 30 天)
显示 更早的评论
Hi
Was just wondering if there was a simple way to flatten a 2d array into correlation rows. Ok so here's an example:
I have n numbers of a 2d array as such:
a b c d e f
1 1.771 1.771 1.771 1.771 2.314 2.314
2 1.802 1.802 1.802 1.802 2.288 2.288
3 2.071 2.071 2.071 2.071 2.184 2.184
4 1.961 1.961 1.961 1.961 2.086 2.086
5 1.94 1.94 1.94 1.94 2.649 2.649
6 1.924 1.924 1.924 1.924 2.458 2.458
7 2.065 2.065 2.065 2.065 2.211 2.211
8 1.981 1.981 1.981 1.981 2.066 2.066
9 1.752 1.752 1.752 1.752 2.108 2.108
10 1.907 1.907 1.907 1.907 2.153 2.153
So say example here a 3d (6x10x n)
How can i correlate a1:a10, b1:b10 till f1:f10 so call them feature a1,a2,a3....f8,f9,f10 and do this for n rows. N rows of 60 features (a1,a2,a3...). Is there a simple matlab function ? Thank you for any help.
Answer for n rows is:
a1 a2 a3 a4 a5 … f8 f9 f10
n1 1.771 1.802 2.071 1.961 1.94 2.066 2.108 2.153
n2
n3
….
Kevin
2 个评论
回答(1 个)
madhan ravi
2018-12-12
编辑:madhan ravi
2018-12-13
Don't even think of creating numbered variables use cell instead
matrix=yourmatrix';
n=size(matrix,1);
result=cell(1,n);
for i = 1:n
result{i}=matrix(i,:);
end
celldisp(result)
5 个评论
madhan ravi
2018-12-13
编辑:madhan ravi
2018-12-13
{ } instead of ( )
n=size(matrix,3);
^--change it to 3 from 1
result{i}=matrix{:,:,i}
If it's not what you are looking for attach your matrix as .mat file
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!