필터 지우기
필터 지우기

Codegen failed to infer output size of built-in function, ??? Dimension 1 is fixed on the left-hand side but varies on the right ([1 x :?] ~= [:? x :?])

조회 수: 1 (최근 30일)
I tried to codegen a large file containing downsample(), below is a simplified one. For some reason, I have to specify the output size. However, coder failed to infer the size of output of dowmsample().
function a = zzz_tmp0329_33(n)%#codegen
coder.varsize('a', [1 Inf], [0 1] );
b = [1,2,3,4];
a = downsample(b, n);
end
Below is the script to run codegen
% ZZZ_TMP0329_33_SCRIPT Generate static library zzz_tmp0329_33 from
% zzz_tmp0329_33.
%
% Script generated from project 'zzz_tmp0329_33.prj' on 14-Sep-2022.
%
% See also CODER, CODER.CONFIG, CODER.TYPEOF, CODEGEN.
%% Create configuration object of class 'coder.CodeConfig'.
cfg = coder.config('lib','ecoder',false);
cfg.GenerateReport = true;
cfg.ReportPotentialDifferences = false;
cfg.GenCodeOnly = true;
%% Define argument types for entry-point 'zzz_tmp0329_33'.
ARGS = cell(1,1);
ARGS{1} = cell(1,1);
ARGS{1}{1} = coder.typeof(0);
%% Invoke MATLAB Coder.
codegen -config cfg zzz_tmp0329_33 -args ARGS{1}
The error says ??? Dimension 1 is fixed on the left-hand side but varies on the right ([1 x :?] ~= [:? x :?]). Why would it say downsample a vector leads to size [:? x :?] ?
Do you know why coder cannot determine the size of output from downsample()?

답변 (1개)

David Fink
David Fink 2022년 9월 14일
Thank you for reporting this!
There have been some changes to downsample - try a recent version of MATLAB - R2021b or newer, where this is fixed.
  댓글 수: 2
Xingwang Yong
Xingwang Yong 2022년 9월 15일
It works on R2022a on my PC. Unfortunately, I have to use this on a workstation, which only has R2020a installed because the OS is CentOS7 and the newest version it supports is R2020a. Do you know how I can solve this with R2020a?
David Fink
David Fink 2022년 9월 15일
In R2020a, you could reshape the output of downsample to the expected 1x?:
a = reshape(downsample(b, n), 1, []);
which (similar to upgrading to R2021b or newer) would allow you to remove the coder.varsize declaration.

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

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by