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
Rik
2020년 11월 10일
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
2020년 11월 10일
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
2020년 11월 10일
Rik
2020년 11월 10일
"skosnosc(daily_logreturns)" does not occur in that file. What does occur in that file is 4 calls to eval too many.
Julian Wzorek
2020년 11월 10일
Rik
2020년 11월 10일
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
2020년 11월 10일
@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.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!