Dimension 1 is fixed on the left-hand side but varies on the right ([512 x 512] ~= [:? x :?]).

조회 수: 18 (최근 30일)
Dimension 1 is fixed on the left-hand side but varies on the right ([512 x 512] ~= [:? x :?]).
Function 'sys3' (#36.430.433), line 24, column 1: "img" Launch diagnostic report.
Errors occurred during parsing of MATLAB function 'test03/sys3'
'img' is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify 'img' is defined in terms of non-tunable parameters, or select the 'Variable Size' check box and specify the upper bounds in the Size box.
Input data is imported from the workspace.
function img = system3(lambd, m, n)
U = lambd;
V = lambd;
W = lambd;
X = ones(1, m*n);
for i = 1:m*n
U = mod(12*U, 251);
V = mod(13*V, 241);
W = mod(14*W, 239);
X(i) = mod(U+V+W, 256);
end
img = reshape(X, m, n);
end

채택된 답변

Fangjun Jiang
Fangjun Jiang 2023년 2월 4일
  1. m and n are specified as "Input" to the MATLAB Function block, so their value could vary during simulation although you probably intended to just provide constant values for them.
  2. Thus "img" is regarded as a variable-size variable. You should check that "Variable size" option for "img" and likely this error will disappear.
  3. Once "Variable size" is checked. [512 512] is regarded as the maximum size which is the same as "upper bonds" mentioned in the message. You need to make sure m and n not exceed 512.
  4. If m and n are from workspace, then mark the scope of m and n as "Parameter", not "Input". Then you might not need to check the "Variable size" option. Try it. I don't remember whether img is still regarded as variable size or not in that case.
  5. Once m and n are marked as parameters, the input port for m and n don't exist anymore but they still appear in the function input argument.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 2월 4일
편집: Walter Roberson 2023년 2월 4일
in the interface block you specified the signal size as 512 by 512. It is not marked as variable sized, and the 512 512 will not be treated as maximum dimensions.
However you assign to the output something that is m by n where those are input parameters. If you wish to create constant size output then ignore the m n passed in and assign 512 to them.
  댓글 수: 1
wang
wang 2023년 2월 4일
편집: wang 2023년 2월 4일
Thank you for your reply, but I don't quite understand what you mean, the m n input parameter is obtained in the workspace, how should I ignore m n and allocate 512.

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

카테고리

Help CenterFile Exchange에서 Buffers, Switches, and Counters에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by