MATLAB Answers

Function Error [scipt works, as interpreted function not]

2 views (last 30 days)
Dear Team,
I have really annoying problem related to function.
I have 2 inputs for my function:
fncc.JPG
prob_ego input is aray: u = [a b c d e f]
location_ego is int loc
output : out = [g h i j k l] (each output is matrix [2x15] and converted to [1x30] by matlab.
If I don't use location_ego input; there isn't any problem. When I use that input (to calculate outputs), I receive error in Simulink although when I run as script; it works without error.
I use inputs of function as both :
function oout = prr(u)
a=u(1);
b=u(2);
c=u(3);
d=u(4);
e=u(5);
f=u(6);
g=u(7);
function oout = prr(u,g)
a=u(1);
b=u(2);
c=u(3);
d=u(4);
e=u(5);
f=u(6);
Error message what is received:
Invalid setting for input port dimensions of 'prrdeneme/Demux'. The dimensions are being set to 1.
This is not valid because the total number of input and output elements are not the same
Error in port widths or dimensions. Output port 1 of 'prrdeneme/Interpreted MATLAB Function' is a one
dimensional vector with 1 elements.
But I don't receive this error when I run the function as script.
Thank you in advance for your answers.
Best regards.

  0 Comments

Sign in to comment.

Accepted Answer

Hakan Basargan
Hakan Basargan on 4 Oct 2019
I solved my problem by adding Signal Specification block output between demux and interpreted function.
Thanks

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by