MATLAB Answers

0

Why I get this error? how can I solve it?

Asked by hanif hamden on 26 Sep 2018
Latest activity Commented on by hanif hamden on 3 Oct 2018
Error in returnindex (line 2) n=length(X);
Output argument "ind" (and maybe others) not assigned during call to "returnindex".
Error in BinData (line 28) Y(i,1)=returnindex(X(i),Value)-1;

  0 Comments

Sign in to comment.

1 Answer

Answer by Fangjun Jiang
on 26 Sep 2018
 Accepted Answer

Need your returnindex.m to see the problem. Most likely, it has a output argument called "ind" but was not assigned.

  4 Comments

Show 1 older comment
clear; clc
%Input Value=dlmread('std_tx.asc'); mValue=max(Value(:,1)); n=length(Value);
%Bin Data for every two(2)km C=0; for j=2 : 2 : mValue C=C+1; X(C)=j; end
C1=0;
for P=1: 2 : mValue
C1=C1+1;
X1(C1)=P;
end
X=X'; X1=X1';
n1=length(X); Y=ones(n1,1); for i=1 : n1 Y(i,1)=returnindex(X(i),Value)-1; end
n2=length(X1); Y1=ones(n2,1); for i=1 : n2 Y1(i,1)=returnindex2(X1(i),Value); end
for i=1 : n1
%fprintf('%.f : %.f\n',Y1(i,1),Y(i,1));
end
std=ones(n1,1); stdValue=Value(:,2); for i=1 : n1 std(i,1)=mean(stdValue(Y1(i,1):Y(i,1))); end
% %OUTPUT
fid1=fopen('std_txR.asc','w'); %std_txR.asc fprintf(fid1,'Mean-Dist(km) Mean-Std(m)\n');
for i=1 : n1 fprintf(fid1,'%d %.5f\n',X(i),std(i,1)); end fclose(fid1);
this is overall script actually.
in returnindex.m, based on the condition, "ind" could never be evaluated.
Yes. it is due to arrangement of the data. I found the solution. Thanks btw

Sign in to comment.