Borrar filtros
Borrar filtros

vertcat double and cell

1 visualización (últimos 30 días)
Trader
Trader el 4 de Abr. de 2012
I have a structure called results that looks like this:
results =
time: [256x1 double]
action: {256x1 cell}
time is filled with serial dates that I'd like to convert to strings and action contains strings like 'waiting', 'open', 'close'
when I try horzcat(results.time, results.action) I get an error saying CAT arguments dimesions are not consistent
I've also tried cat(2, results.time, results.action) and ge tthe same error
thanks

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Abr. de 2012
strcat(cellstr(datestr(results.time)), {' '}, results.action)
  1 comentario
Trader
Trader el 5 de Abr. de 2012
Thanks, Leah and Walter, your suggestions solved my problem!

Iniciar sesión para comentar.

Más respuestas (1)

Leah
Leah el 4 de Abr. de 2012
you have to convert so you have the same data types. I converted the double to a cell array.
results.time=[1:256]';
results.action=repmat({'hi'},256,1)
horzcat(num2cell(results.time),results.action)

Categorías

Más información sobre Dates and Time 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