Problem with a function
显示 更早的评论
Hi, I would like to creat a function that calculate fn. I would like to assign 1 to s when x>v and 0 otherwise.
[fn]=lillietest1(daily_logreturns);
function [fn] = lillietest1(x)
n=lenght(x);
x=sort(x);
for i=1:n
v(i)=i/n;
if x(i)>=v(i)
s(i)=1;
else
s(i)=0;
end
end
fn=sum(s)/n;
end
采纳的回答
更多回答(1 个)
Alan Stevens
2020-11-11
Try changing
n=lenght(x);
to
n=length(x);
(Notice the spelling).
4 个评论
Julian Wzorek
2020-11-11
Alan Stevens
2020-11-11
You must be running it from the command window. Save it as a script and run the script.
Julian Wzorek
2020-11-11
编辑:Julian Wzorek
2020-11-11
Julian Wzorek
2020-11-11
类别
在 帮助中心 和 File Exchange 中查找有关 Agriculture 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!