Matlab function in simulink
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Pramil
le 26 Nov 2024 à 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 commentaires
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!