Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
JL555
JL555 le 9 Sep 2015
Modifié(e) : JL555 le 3 Mai 2016
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?

Réponse acceptée

James Tursa
James Tursa le 9 Sep 2015
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 commentaires
Stephen23
Stephen23 le 9 Sep 2015
Modifié(e) : Stephen23 le 9 Sep 2015
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 le 9 Sep 2015
Modifié(e) : JL555 le 9 Sep 2015
@Stephen-would really help if you give an example with that second script

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 9 Sep 2015
At the bottom you have
function z=fun(U)
z='FPAeld1';
end
Change that to
function z = Fun(U)
z = FPAeld1(U);
end
  8 commentaires
JL555
JL555 le 9 Sep 2015
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 le 9 Sep 2015
Poster extracted this error into a new Answer.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Historical Contests dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by