フィルターのクリア

Correlate a 3d array into n times 2d rows

3 ビュー (過去 30 日間)
Kevin Teh
Kevin Teh 2018 年 12 月 12 日
編集済み: madhan ravi 2018 年 12 月 13 日
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 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 12 日
example of your output?
Kevin Teh
Kevin Teh 2018 年 12 月 12 日
Sure sorry say n number of rows:
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
.

サインインしてコメントする。

回答 (1 件)

madhan ravi
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 件のコメント
Kevin Teh
Kevin Teh 2018 年 12 月 13 日
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in addHeader (line 19)
result(i)=matrix(i,:);
my matrix is 165x165x59 cell
madhan ravi
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 ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by