Programmatically change function input

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?

 采纳的回答

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 个评论

I knew I was missing something obvious. This worked perfectly. Thank you.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Timetables 的更多信息

产品

版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by