Borrar filtros
Borrar filtros

Correlate a 3d array into n times 2d rows

3 visualizaciones (últimos 30 días)
Kevin Teh
Kevin Teh el 12 de Dic. de 2018
Editada: madhan ravi el 13 de Dic. de 2018
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 comentarios
madhan ravi
madhan ravi el 12 de Dic. de 2018
example of your output?
Kevin Teh
Kevin Teh el 12 de Dic. de 2018
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
.

Iniciar sesión para comentar.

Respuestas (1)

madhan ravi
madhan ravi el 12 de Dic. de 2018
Editada: madhan ravi el 13 de Dic. de 2018
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 comentarios
Kevin Teh
Kevin Teh el 13 de Dic. de 2018
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 el 13 de Dic. de 2018
Editada: madhan ravi el 13 de Dic. de 2018
{ } 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

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by