Simulink Matlab Function size mismatch error
古いコメントを表示
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
2018 年 11 月 14 日
Berkin Birol
2018 年 11 月 15 日
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 件)
カテゴリ
ヘルプ センター および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!