Problem with a function
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Alan Stevens
il 11 Nov 2020
Try changing
n=lenght(x);
to
n=length(x);
(Notice the spelling).
4 Commenti
Julian Wzorek
il 11 Nov 2020
Alan Stevens
il 11 Nov 2020
You must be running it from the command window. Save it as a script and run the script.
Julian Wzorek
il 11 Nov 2020
Modificato: Julian Wzorek
il 11 Nov 2020
Julian Wzorek
il 11 Nov 2020
Categorie
Scopri di più su Agriculture in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!