Simulink Matlab Function size mismatch error

8 visualizaciones (últimos 30 días)
Berkin Birol
Berkin Birol el 14 de Nov. de 2018
Comentada: Caspar Hanselaar el 22 de Sept. de 2021
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 comentarios
Berkin Birol
Berkin Birol el 15 de Nov. de 2018
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 el 22 de Sept. de 2021
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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by