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:
- Undefined function 'TMAP.m' for input arguments of type 'double'.
- Error evaluating MATLAB function in 'VelocitySelectiveRecordingTMAP/TMAP'
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
2019년 5월 24일
Try leaving out the .m part in the properties, just specify the function name not the file name
Beatrice Pazzucconi
2019년 5월 29일
Beatrice Pazzucconi
2019년 5월 30일
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
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Signal Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!