Cell arrays as top-level function outputs are not supported in MATLAB Function Block
Ältere Kommentare anzeigen
Hi, all.
I have a trouble with making an output as a cell array in MATLAB function block in Simulink.
I tried to split a string with '\n' character into the cell array.
My function is shown below, it is simple code to output the cell array.
This cell array contains multiple strings.
function y = fcn(u)
s = 'test\ntest2\ntest3';
s_end = size(s,2);
% sp_s = {};
% sp_s = strsplit(s, '\n');
k = strfind(s, '\n');
sz_k = size(k,2);
out_elems = [];
out_elems = cell(sz_k+1,1);
for i = 1:1:sz_k+1
if i == 1
temp_pos = k(1,i);
temp_str = s(1:temp_pos-1);
elseif i == sz_k+1
pre_temp_pos = k(1,i-1);
temp_str = s(pre_temp_pos+2:s_end);
else
temp_pos = k(1,i);
pre_temp_pos = k(1,i-1);
temp_str = s(pre_temp_pos+2:temp_pos-1);
end
out_elems{i,1} = temp_str;
end
% temp_out = out_elems(1:sz_k+1,1);
y = out_elems;
And I got the following error.
Cell arrays as top-level function outputs are not supported in MATLAB Function Block. Output 'y' is a cell array.
Do you have any idea to solve this error in Simulink?
Thank you in advacned.
Best,
Yun
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Communications Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!