필터 지우기
필터 지우기

ERROR IN USEAGE OF INTERP2

조회 수: 2 (최근 30일)
VGC
VGC 2012년 11월 7일
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...

답변 (5개)

Walter Roberson
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
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".

VGC
VGC 2012년 11월 7일
OK, IF I REMOVE THAT STATEMENT THEN 4 DIFFRENT ERRORS ARE BEING SHOWN...
  댓글 수: 3
VGC
VGC 2012년 11월 8일
es = epsilon_sample(A,B);
Jan
Jan 2012년 11월 8일
@VGC: Whenever you write the term "error message" in this forum, you can be sure, that the audience wants to see this message also. Please note that it is a rather rare situation to get 4 error messages, because Matlab stops after the first in general...

댓글을 달려면 로그인하십시오.


VGC
VGC 2012년 11월 7일
MY PURPOSE BEHIND THAT STATEMENT IS TO DEFINE epsilon_sample AS A FUNCTION OF X AND Y. HOW SHOULD I DO IT OTHERWISE??
  댓글 수: 2
Walter Roberson
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.
Jan
Jan 2012년 11월 8일
편집: Jan 2012년 11월 8일
@VGC: UPPER CASE means SHOUTING in internet forums. So please use this with care.
Functions are defined either as M-files or as anonymous functions in Matlab. es = epsilon_sample(A,B) does not match one of these cases.

댓글을 달려면 로그인하십시오.


VGC
VGC 2012년 11월 8일
then how am i to use it in interp2 ??
  댓글 수: 2
Walter Roberson
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
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 CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by