Filter löschen
Filter löschen

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 :?])

2 Ansichten (letzte 30 Tage)
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);
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.
%% 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()?

Antworten (1)

David Fink
David Fink am 14 Sep. 2022
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 Kommentare
Xingwang Yong
Xingwang Yong am 15 Sep. 2022
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 am 15 Sep. 2022
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.

Melden Sie sich an, um zu kommentieren.




Community Treasure Hunt

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

Start Hunting!

Translated by