ERROR IN USEAGE OF INTERP2
1 次查看(过去 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!