필터 지우기
필터 지우기

Simulink Matlab Function size mismatch error

조회 수: 16 (최근 30일)
Berkin Birol
Berkin Birol 2018년 11월 14일
댓글: Caspar Hanselaar 2021년 9월 22일
Hello all,
I use the following matlab function in a Simulink Matlab Function.
function [igtby, igty] = fcn(input1, input2, ..., input n)
igtby=zeros(1,34);
igty=zeros(1,34);
While compiling, I get the following error, it drives me crazy:
"Size mismatch (size [34 x 1] ~= size [1 x 34]). The size to the left is the size of the left-hand side of the assignment. Function 'Model ayrık/TrendekiBosYer_TrendenInenler_FnBlck/MATLAB Function' (#10209.126.131), line 2, column 1: "igtby" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error"
igtby is not an input, it is not written anywhere. The output properties are normal as you can see in the following figure. What am I doing wrong and not finding it out? By the way diagnostic report says exactly same as the error, sizes mismatch.
  댓글 수: 3
Berkin Birol
Berkin Birol 2018년 11월 15일
update:
Problem is solved, but how??
igtby is obviously an output and connected to something. I removed the variable from output table, then I tried to run the simulation. Bingo, it worked. Than step by step, first igtby becomes an output again, but it is not connected to anything. Again, successfully completed the simulation. Then, finally, connected the igtby output to the same place before (everything is exactly same as I get the error message). Bammm, still worked. Meaningless, ridiculous, but now the exact same combination works. non-deterministic error I think, Hope doesn't decide to give same error again.
Caspar Hanselaar
Caspar Hanselaar 2021년 9월 22일
Like your problem, I encountered a similar issue in R2021a:
An element-wise multiplication in the form of the following:
function bbox_interp = interpolate_bounding_box2(bbox_past,time_past,bbox_future,time_future,target_time)
% function to linearly interpolate bounding box (bbox) position
ratio = (target_time-time_past)/(time_future-time_past);
bbox_interp = bbox_past + (bbox_future - bbox_past).*ratio;
end
Gave the following error:
Size mismatch detected: [4][2] ~= [1][1]
I managed to track it down to it interpreting the 'ratio' as a [1][1] matrix, rather than a scalar variable.
Solved it by accessing the first entry of the [1][1] matrix;
function bbox_interp = interpolate_bounding_box2(bbox_past,time_past,bbox_future,time_future,target_time)
% function to linearly interpolate bounding box (bbox) position
ratio = (target_time-time_past)/(time_future-time_past);
bbox_interp = bbox_past + (bbox_future - bbox_past).*ratio(1);
end

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Configure and View Diagnostics에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by