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

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;

 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

function ind=returnindex(c,X)
n=length(X);
for i = 1 : n
Y = X(i,1);
if Y > c
ind = i;
break;
end
end
this is my returnindex.m
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.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!