Hi, I'm working on a function that will build a synchronized timetable based on a varying number of data streams. The function organizes that data into a cell array, and then feed those cells are fed into the synchronize function.
Here's a chunklet of the code:
for i=1:length(synccell)
catstring=sprintf('synccell{%u}',i);
fncstr=strcat(fncstr,catstring,',');
end
finalstr=strcat(fncstr,"'regular','next','TimeStep',seconds(.05))");
tt=synchronize(finalstr)
writetimetable(tt,'Synchronized.csv');
Obviously, this doesn't work because I can't just use a string as a function input.
What are my options here?

 채택된 답변

Stephen23
Stephen23 2021년 1월 6일
편집: Stephen23 2021년 1월 6일

0 개 추천

Using a character vector is entirely the wrong approach. The correct approach is to use a comma-separated list:
tt = synchronize(synccell{:},'regular','next','TimeStep',seconds(.05));
% ^^^^^^^^^^^ comma-separated list from cell array

댓글 수: 1

Alex Browning
Alex Browning 2021년 1월 6일
I knew I was missing something obvious. This worked perfectly. Thank you.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2021년 1월 6일

댓글:

2021년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by