我不明白为什么我会收到这个错误而且我用谷歌搜索了它,但我没有得到任何满意的答案。谷歌上的很多地方都说这是因为输入数据的形状不好。
我的代码:
%defining variables
N=100;
n=23;
theta=zeros(1,N);
beta=zeros(1,N);
data=[17.88 28.92 33.00 41.52 42.12 45.60 48.40 51.84 51.96 54.12 55.56 67.80 68.64 68.64 68.88 84.12 93.12 98.64 105.12 105.84 127.92 128.04 173.40 ];
x=[0:0.1:2];
i=1;
sum1=0;
sum2=0;
sum3=0;
k=0;
mean_beta=0;
mean_theta=0;
%For the case NO Censoring
%Repeating the experiment to get better results
for k=1:N
data=sort(data);
for i=1:n
t=data(i);
sum1=sum1+(t.^x)*log(t);
sum2=sum2+t.^x;
sum3=sum3+log(t);
end
%Calculating Value of Beta
f= @(z)(( sum((data(1):data(n)).^z).*(log(data(1):data(n)))/ sum((data(1):data(n)).^z)) - (sum3/n)-(1/z));
beta(k)=fsolve(f,3.);
mean_beta=mean_beta+beta(k);
%Calculating value of Theta
theta(k)= (sum((data(1):data(n)).^beta(k))/n)^(1/beta(k));
mean_theta=mean_theta+theta(k);
end
%Final Value
mean_theta=mean_theta/N;
mean_beta=mean_beta/N;