How to convert a cell into column vector

Hi,
I have cell A (1x1). How to convert this into a vector of 1x150?

8 comentarios

Walter Roberson
Walter Roberson el 31 de Oct. de 2019
Editada: Walter Roberson el 31 de Oct. de 2019
What is inside the cell?
size(A{1})
By the way, 1 x 150 is a row vector not a column vector. Do you want 1 x 150, or 150 x 1 ?
Parthu P
Parthu P el 31 de Oct. de 2019
The cell is average temperature. I want 1 x 150.
Thanks.
Okay, so what was
size(A{1})
Parthu P
Parthu P el 31 de Oct. de 2019
Sorry, it didn't work.
What didn't work? If you do have a cell array A as you say, then
size(A{1})
is guaranteed to return a result. We need to know what that result is in order to help you (or in other words, we need to know what's in the cell array.
Parthu P
Parthu P el 31 de Oct. de 2019
Thanks.
I have
A = 35.2 (1x1)
I need [A] = [35.2 35.2 35.2 . . . . . . . . . . . . . . 35.2] (1x150).
Adam
Adam el 31 de Oct. de 2019
Editada: Adam el 31 de Oct. de 2019
A{1} * ones(1,150)
would give you that then I guess. Or use
doc repmat
if you want to be fancy.
It would help if you used clearer terminology though. 'Convert a cell to a column vector' implies the cell is already of the size you want the column vector to be, either itself or the element inside its cell.
What you want to do is replicate a value 150 times.
Parthu P
Parthu P el 31 de Oct. de 2019
Perfect!
Thanks.

Iniciar sesión para comentar.

 Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 31 de Oct. de 2019
Editada: KALYAN ACHARJYA el 31 de Oct. de 2019
Here result represents resultant A
A=35.2;
result=repelem(A,150)
If A is the single cell arrray then
A={35.2};
result=repelem(A,150)
Hope it helps!

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 31 de Oct. de 2019

Comentada:

el 31 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by