Matlab function in simulink
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Errors occurred during parsing of MATLAB function 'MATLAB Function'(#35)
Error in port widths or dimensions. Output port 1 of 'rectinput/MATLAB Function/d' is a one dimensional vector with 1 elements.
my coding is
function y = fcn(a,b,c,d)
%#codegen
v = rectangle('Position',[a b c d]);
axis ([0 10 0 10]);
y = v;
0 comentarios
Respuestas (1)
Pramil
el 26 de Nov. de 2024 a las 10:11
Hey Vimala,
The error you're encountering is related to the output dimensions of the "MATLAB function" block.
In your code, you're trying to assign the output "y" to the result of the "rectangle" function, which doesn't return a numeric value but rather a handle to the rectangle object. This is likely causing the mismatch in expected output dimensions.
If your goal is to visualize a rectangle and not return any specific numeric output, you might want to adjust your function so that it doesn't attempt to return the handle.Here's a modified version of your function:
function fcn(a, b, c, d)
%#codegen
rectangle('Position', [a, b, c, d]);
axis([0 10 0 10]);
end
If you need to return some specific information about the rectangle, such as its position or size, you can adjust the function accordingly. Here's an example of returning the position vector:
function pos = fcn(a, b, c, d)
%#codegen
rectangle('Position', [a, b, c, d]);
axis([0 10 0 10]);
pos = [a, b, c, d]; % Return the position vector
end
Hope it helps.
0 comentarios
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!