How can i reshape a 20370x1 matrix into 2037x10x1?

2 visualizaciones (últimos 30 días)
shubhi bhadauria
shubhi bhadauria el 15 de Jul. de 2015
Comentada: shubhi bhadauria el 15 de Jul. de 2015
I have tried to execute this using reshape and permute command.The problem is i am getting either the dimensions as 2037x1x10 or 2037x10. I want the dimension to be 2037x10x1. This is the solution i come up with so far,
>> r=permute(reshape(modu_data_QAM',2037,10),[2;3;1]);
The result= 10 1 2037
modu_data_QAM is a matrix of 20370x1 dimension.

Respuesta aceptada

John D'Errico
John D'Errico el 15 de Jul. de 2015
Editada: John D'Errico el 15 de Jul. de 2015
MATLAB treats ALL matrices as having essentially an infinite number of trailing singleton dimensions. So a 2x3 matrix is really 2x3x1x1x1x1x1x1... Those trailing singleton dimensions are not reported by size or whos however.
X = zeros(2,3,1,1);
whos X
Name Size Bytes Class Attributes
X 2x3 48 double
size(X)
ans =
2 3
However, MATLAB indeed knows that X has trailing singleton dimensions. You can convince yourself of that easily enough.
size(X,3)
ans =
1
size(X,12)
ans =
1
Your 2037x10 matrix is indeed a 2037x10x1 matrix. So a simple reshape was all you needed to do.
B = reshape(A,[2037,10]);
  1 comentario
shubhi bhadauria
shubhi bhadauria el 15 de Jul. de 2015
Thanks for the reply. Actually i was trying to use the step command for getting a modulated OFDM signal.Thus this error was coming up,that the input should be 2037x10x1. I'll look into my code again> Thanks once again:)

Iniciar sesión para comentar.

Más respuestas (1)

dpb
dpb el 15 de Jul. de 2015
All arrays in Matlab have implied but not explicit unity dimensions in higher dimensions; you can refer to the array with the third subscript explicitly if need to.
Smaller example of same thing...
>> x=rand(200,1);
>> size(x)
ans =
200 1
>> y=reshape(x,20,10,1);
>> size(y)
ans =
20 10
>> y(20,10)==y(20,10,1)
ans =
1
>>
As you can see, referring to the resulting y array with either two or an explicit third (unity) index results in the same thing.
Why do you think you need the explicit third dimension; show us some code snippets of what you're after that can't seem to accomplish (other than just wishing the implicit dimension would show up with size, say).

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by