Error in vector dimension, and too many outputs. How can I make this easier?

1 次查看(过去 30 天)
Can anyone help me please? I have tried different types of vectors and it doesn't work. I am getting two errors, first:
??? Undefined function or method 'Sqrt' for input arguments of type 'double' and then too many outputs. I would really appreciate if anyone could tell me an example of the vectors and if there is any other mistake. Thanks
V=reshape(V,length(V),1);
alpha = alpha/2; %
n=length(V);
i=0;S=0;
for i=1:n-1
S = S + sum(sign(V(i+1:n) - V(i)));
end
h=1;
while ~isempty(V)
g=find(V==V(1));
tp=length(g);
Sum(h)=tp*(tp-1)*(2*tp+5);
V(g)= [];
h=h+1;
end
VarS=((n*(n-1)*(2*n-5))-sum(Sum))/18;
%Standard deviation
De=Sqrt(VarS);
If S>=0;
Z= ((S-1)/De)*(S~=0);
else
z= ((S+1)/De);
end
p_value=2*(1-normcdf(abs(z),0,1)); % tail on both sides
pz=norminv(1-alpha,0,1);
H=abs(z)>pz;
return

回答(1 个)

Guillaume
Guillaume 2015-5-23
I've not checked your code for the validity of your inputs, but the main reason for 'the undefined function xxx for input argument of type yyy' is usually because function xxx is misspelled or not on the path. 99% of the cases it has nothing to do with the argument type.
In your particular case, the square root function is spelled sqrt with a lowercase 's'. Therefore,
De = sqrt(VarS);
should solve the issue.

类别

Help CenterFile Exchange 中查找有关 Oceanography and Hydrology 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by