Local function is unrecognized.
Mostrar comentarios más antiguos
Hi, so I wrote this function for skewness at the end of my script :
function [s]=skosnosc(x)
n=length(x);
s=(((sum((x-mean(x)).^3)))/n)/(((((sum((x-mean(x)).^2)))/n).^0.5).^3);
end
And tried to use it on my data which is called daily_logreturns and is a vector 9634x1 double.
I tried to just insert it like that : skosnosc(daily_logreturns) but there is a problem : Unrecognized function or variable 'skosnosc'.
Thank you in advance!!!
7 comentarios
Rik
el 10 de Nov. de 2020
Did you call it like that in your script file? If you so, please attach your script file with the paperclip icon.
John D'Errico
el 10 de Nov. de 2020
My bet is the function is defined in a script, but then he is trying to call the function in the command window.
Julian Wzorek
el 10 de Nov. de 2020
Rik
el 10 de Nov. de 2020
"skosnosc(daily_logreturns)" does not occur in that file. What does occur in that file is 4 calls to eval too many.
Julian Wzorek
el 10 de Nov. de 2020
Rik
el 10 de Nov. de 2020
By storing the data in an array in the first place.
(I have taken the liberty of adapting some of Stephen Cobeldick's thoughts on this topic) Introspective programing (e.g. eval, assignin and other functions like it) is slow, and the MATLAB documentation warns specifically against it. Using eval is slow, makes debugging difficult, and removes all code helper tools (code checking, syntax hints, code completion, variable highlighting, etc.). A longer discussion can be found here. If you are not an expert and you think you need eval, there are probably better solutions to your problem. Also, if you are not an expert, you might find interesting and helpful hints on this page (and if you are an expert, you can still learn from it).
Stephen23
el 10 de Nov. de 2020
@Julian Wzorek : load into an output variable (which is a scalar structure):
S = load(..);
and then access its fields. Relying eval for basic data accessing is not a good approach.
Respuestas (0)
Categorías
Más información sobre Multidimensional Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!