Undefined function for input arguments of type 'double' during Simulink

Hello everyone, I created a simple script (TMAP.m) that has the current body:
function y = TMAP(u)
A = 40e+03;
B = 15e+03;
n = 1;
y = A*(u.^n).*exp(-B*u);
end
And I added the block "Interpreted Matlab function" to my Simulink model. I indicated "TMAP.m" in the block properties, fed a digital clock as input and connected to output to a scope. The TMAP script is in the same folder as the Simulink model. When in workspace I create a dummy input vector, say 0:0.001:0 and feed it to TMAP (eg y = TMAP(0:0.001:1)) it works just fine. When I try to run the Simulink model, I get these errors:
Can anybody tell me what I am doing wrong?
THank you very much for your help
NB - tried also having TMAP doing y = sin(u) to be sure but still refuses to work

5 件のコメント

Walter Roberson
Walter Roberson 2019 年 5 月 24 日
Try leaving out the .m part in the properties, just specify the function name not the file name
Beatrice Pazzucconi
Beatrice Pazzucconi 2019 年 5 月 29 日
Hi Walter,
thank you very much, now it actually runs the model but the output signal is a flat line. May it be I got the sample time wrong?
Beatrice
Beatrice Pazzucconi
Beatrice Pazzucconi 2019 年 5 月 30 日
Yeah, that was it, it was enough to play a little bit with sampling time
Thank you bunches!
wei-jay ling
wei-jay ling 2023 年 1 月 9 日
編集済み: wei-jay ling 2023 年 1 月 9 日
Hi, I have same problem, but I don't know your mean.
If I change the file name (like planer.m become planerA.m) then the system will show the warning to me.
the problem show below,please help me.
Walter Roberson
Walter Roberson 2023 年 1 月 10 日
The original poster had the problem that inside their simulink block, at a place that they needed to refer to function TMAP they instead referred to function TMAP.m -- the file name instead of the function name. This had nothing to do with renaming anything, just with changing the way the function was referred to in the code.
There should be no need to rename planer.m to planerA.m .
If you do rename a file that has a function inside it as the first line non-comment, then you might get a warning message that the name in the function statement does not match the name of the file. If you renamed planer.m to planerA.m then best practice would be to also rename function planer inside the now-called planerA.m to function planerA inside that file.
In your case, Simulink is trying to find a function named planar (with an ar not an er) but is not succeeding. If you do have a planar.m file then it is not anywhere on your MATLAB path. You should consider using pathtool to ensure that th directory containing planar.m is on your MATLAB path.

サインインしてコメントする。

 採用された回答

Beatrice Pazzucconi
Beatrice Pazzucconi 2019 年 5 月 30 日
編集済み: Beatrice Pazzucconi 2019 年 5 月 30 日

0 投票

Answer provided in comments

その他の回答 (0 件)

製品

リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by