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!