Matlab simulink error: Only finite double vector or matrix outputs are supported.

In my simulink model where i am using block "Interpreted Matlab function" and the function is:
function test = testFunc()
test = [int16(0) int16(0)]
i get error :
An error occurred while running the simulation and the simulation was terminated Caused by:
Error in 'test2/Interpreted MATLAB Function'. Evaluation of expression resulted in an invalid output. Only finite double vector or matrix outputs are supported
Edit: It crashes in second iteration
What am i doing wrong? Thanks for help

1 Comment

I have tried by use coder.nullcopy() and it works.
function d=functionsx(s)
a=[5 5 6; 7 6 8];
b=a+s;
d = coder.nullcopy(zeros(size(b)));
d=b

Sign in to comment.

 Accepted Answer

Why interpreted matlab function for a function like this? Can't you use instead Data Type Conversion block for it?

5 Comments

this is obviously my test function, real function should output two int16. after a long time i found out that it outputs this error when the two ints are 0. So i need to use interpreted matlab function
Write your function in that block, but let the outputs be double. Then connect those outputs to Data Type Conversion block and convert them to int16.
ok, it works but why outputting two int16 zeros causes error?
At the end of the page, you'll see Characteristics pane and there, Data Types->Double is written

Sign in to comment.

More Answers (1)

Maybe your function output is not a double type data, change your output to a double type data and see if it works? I have met the same problem before and I solve it out by changing my output data to double type using "output=double(output)". Hope this is helpful.

3 Comments

Hi Xiaoxiong,
Excuse me.
I encountered the same problem now, I tried your methods, but it didn't work, could you please give some clues? Thanks. The problems are described as follows:
In simulink, I used the interpreted MATLAB function, to call for HEX_LT function, it works.
But if there is a subfunction (like SFHC) within the HEX_LT function, shown as follows:
function y = HEX_LT(para)
hex = SHFC (Pa_in, Ga, Qw, di, Tb);
Uo = 1/(1/ho + do^2 /(hex(i)* di^2));
... y = T;
end
I have tried several ways, but all didn't work, all told me that ' Evaluation of expression resulted in an invalid output. Only finite double vector or matrix outputs are supported', could you please help with this?
Thanks, and looking forward to your reply.
Hi,Ting Liang,
Excuse me,
I encountered the same problem too,have you solved this problem now?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!