필터 지우기
필터 지우기

vertcat double and cell

조회 수: 1 (최근 30일)
Trader
Trader 2012년 4월 4일
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

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 4일
strcat(cellstr(datestr(results.time)), {' '}, results.action)
  댓글 수: 1
Trader
Trader 2012년 4월 5일
Thanks, Leah and Walter, your suggestions solved my problem!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Leah
Leah 2012년 4월 4일
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)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by