ERROR IN USEAGE OF INTERP2
조회 수: 2 (최근 30일)
이전 댓글 표시
MAX = 201;
[With]=xlsread('Withoutnew.xlsx',1);
[X,Y]=meshgrid(linspace(-2,6,MAX),linspace(-3,5,MAX));
X=X(:);
Y=Y(:);
A=linspace(-2,6,201);
B=linspace(-3,5,201);
for k=1:cols
epsilon_sample(:,k)=(10.^(-With(:,k)/20)) * 16*1 ;
end
es=epsilon_sample(A,B);
for k= 1:cols
ZI = interp2(A,B, epsilon_sample(:,k), X(:),Y(:),'spline');
end
ERROR:Undefined function 'epsilon_sample' for input arguments of type 'double'.
Pls. tell how to resolve this error...
댓글 수: 0
답변 (5개)
Walter Roberson
2012년 11월 7일
You do not show any definition for "cols". If it is defined but less than 1, then you would not initialize epsilon_sample within the loop, and then outside the loop it would not have a value and MATLAB would complain about undefined function or variable.
Jan
2012년 11월 7일
epsilon_sample is an array. A and B contain floating point data, which are partially negative and non-integer. Then this line must fail:
es = epsilon_sample(A,B);
The first values of A and B are -2 and -3, but e.g. apsilon_sample(-2, -3) is not a valid Matlab operation. But I'd expect a different error message like "Indices must be positive integers".
댓글 수: 0
VGC
2012년 11월 7일
댓글 수: 2
Walter Roberson
2012년 11월 7일
Which statement?
You have already defined epsilon_sample as an array; you cannot have a single name which is both a function and an array.
VGC
2012년 11월 8일
댓글 수: 2
Walter Roberson
2012년 11월 8일
The first two parameters you pass in to interp2() should be the x and y values that were used to generate the known z values that you pass in the third parameter. The third parameter needs to be a 2D matrix of the known values at those x and y locations. The fourth and fifth parameters should be the x and y for the locations you wish to interpolate.
You are passing A and B in as your first two parameters, but those do not appear to be the actual x and y that were used to generate epsilon_sample. But we don't know, as you have not given us any information about wht the information in your "With" array corresponds to.
Note: you could generate epsilon_sample without a loop:
epsilon_sample = (10.^(-With(:,1:cols)/20)) * 16*1 ;
(Is that something like a decibel conversion ?)
Jan
2012년 11월 8일
@VGC: Please do not use the fields to post answers for repeating the question. The input mask in the forum is split into title, question, tags, answers and comments to the question or to answers. Keeping this order reduces the confusion level of the readers and therefore increases your chance to get a helpful answer.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!