필터 지우기
필터 지우기

Why I get an error when generating a cell array as an output of a simulink function?

조회 수: 4 (최근 30일)
function y = (input,vector)
persistent count
persistent array_3
persistent array_2
persistent array_1
persistent Matrix
if isempty (array_3)
array_3 = cell(1000,2);
%array_3 = cell(repmat({zeros(1,9)}, 100, 1),repmat({zeros(1,9)}, 100, 2));
count = 0;
array_1 = zeros(1,9);
array_2 = zeros(500,16);
end
%Merge
Matrix(1:500,1:15)= data;
Matrix(1:500,16)= input;
%Look through the data
peak = find(Matrix(:,16)== 1);
val = length(peak);
if val > 5
Counter = Counter + 1;
array_3{Counter,1} = array_1;
array_3{Counter,2} = array_2;
end
y = array_3;
Error:
Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
Component:MATLAB Function | Category:Coder error
Cell arrays as top-level function outputs are not supported in MATLAB Function Block. Output 'Output' is a cell array.

답변 (1개)

Mark McBroom
Mark McBroom 2020년 5월 3일
First, it looks like you ahve a typo... should "Counter" be "count"? But that isn't the reason for the error. I think the problem is that even though your code says the kength of array_3 is 1000, the body of the code can go beyond 1000. Try changing this line to be:
if val > 5 && count < 999
Thanks.
Mark.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by