Undefined function 'Fun" for input argument of type 'double'?

조회 수: 19 (최근 30일)
JL555
JL555 2015년 9월 9일
편집: JL555 2016년 5월 3일
function z=fun(U)
z='FPAeld1';
end
i need to call the first script from this algorithm but i'm getting error "undefined function 'Fun'.." why?

채택된 답변

James Tursa
James Tursa 2015년 9월 9일
I see a "fun" but I don't see a "Fun" anywhere. Do you have a file Fun.m that you are trying to call? Or are you trying to call "fun"?
  댓글 수: 12
Stephen23
Stephen23 2015년 9월 9일
편집: Stephen23 2015년 9월 9일
The answer to this is very simple: stop writing scripts and write functions instead. While scripts are great for playing around with some data and getting things going, functions offer many many advantages over scripts, including their own name spaces, algorithm abstraction, the ability to pass variables in and out, and lots of other handy stuff.
Turn your scripts into functions and pass that data as an output.
JL555
JL555 2015년 9월 9일
편집: JL555 2015년 9월 9일
@Stephen-would really help if you give an example with that second script

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2015년 9월 9일
At the bottom you have
function z=fun(U)
z='FPAeld1';
end
Change that to
function z = Fun(U)
z = FPAeld1(U);
end
  댓글 수: 8
JL555
JL555 2015년 9월 9일
Did what u said but now this error comes
Error using *
Inner matrix dimensions must agree.
Error in FPAeld1 (line 35)
F=Pi.*Pi*a1+Pi*b1+c1+mod(ei*sin.*(fi*(pmin-Pi)))
Steven Lord
Steven Lord 2015년 9월 9일
Poster extracted this error into a new Answer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by