Local function is unrecognized.

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 Comments

Did you call it like that in your script file? If you so, please attach your script file with the paperclip icon.
My bet is the function is defined in a script, but then he is trying to call the function in the command window.
"skosnosc(daily_logreturns)" does not occur in that file. What does occur in that file is 4 calls to eval too many.
Could you tell me how could I convert my vector intervals to use it inside loop instead of eval?
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).
@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.

Sign in to comment.

Answers (0)

Categories

Asked:

on 10 Nov 2020

Commented:

on 10 Nov 2020

Community Treasure Hunt

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

Start Hunting!