Azzera filtri
Azzera filtri

ERROR IN USEAGE OF INTERP2

2 visualizzazioni (ultimi 30 giorni)
VGC
VGC il 7 Nov 2012
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...

Risposte (5)

Walter Roberson
Walter Roberson il 7 Nov 2012
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 il 7 Nov 2012
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 il 7 Nov 2012
OK, IF I REMOVE THAT STATEMENT THEN 4 DIFFRENT ERRORS ARE BEING SHOWN...
  3 Commenti
VGC
VGC il 8 Nov 2012
es = epsilon_sample(A,B);
Jan
Jan il 8 Nov 2012
@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...

Accedi per commentare.


VGC
VGC il 7 Nov 2012
MY PURPOSE BEHIND THAT STATEMENT IS TO DEFINE epsilon_sample AS A FUNCTION OF X AND Y. HOW SHOULD I DO IT OTHERWISE??
  2 Commenti
Walter Roberson
Walter Roberson il 7 Nov 2012
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 il 8 Nov 2012
Modificato: Jan il 8 Nov 2012
@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.

Accedi per commentare.


VGC
VGC il 8 Nov 2012
then how am i to use it in interp2 ??
  2 Commenti
Walter Roberson
Walter Roberson il 8 Nov 2012
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 il 8 Nov 2012
@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.

Accedi per commentare.

Categorie

Scopri di più su Data Type Identification in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by