• Register
0 votes

Problem :

I have some of the time/frequency data and I try to interpolate it using a interp2 function of Matlab. My data [F,T,data] is obtained from the different Matlab routine of a Matlab, spectrogram in case you are interested as below.

[~,F,T,data] = spectrogram(...)
data = 10*log10(data);

I can plot my data using surf. My data is fine, I believe. But interpolating my data seems to be the problem. Even using the interp2(F,T,data,F,T) (so actually no interpolating) gives the error as below.


Error using griddedInterpolant
The grid vectors do not define a grid of points that match the given values.
Error in interp2>makegriddedinterp (line 228)
    F = griddedInterpolant(varargin{:});
Error in interp2 (line 128)

What is going wrong here?

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Your problem is that you should swap your  F and T:


Your first argument corresponds with the columns of a matrix and a second argument with a rows.

If X and Y are the grid vectors, then your V must be the matrix containing a length(Y) rows and length(X) columns.

As an alternative, you can take a transpose of data:


Reasoning behind the argument order

interp2(X,Y,V,Xq,Yq) is always interpreted as a interpolation of the function, represented by a matrix V, i.e. a sample values and a problem is that the arguments/indexes of the function/matrix are rather supplied in the opposite order:

matrix(row, column)



Here x (first argument) often represents a horizontal axes and therefore corresponds with a  column (second argument) argument and idem for the y and row.

9 7 4
38,600 points

Related questions

0 votes
1 answer 4 views
Problem: I have some time/frequency data and I try to interpolate it using the interp2 function of Matlab. The data [F,T,data] is obtained from a different Matlab routine of Matlab, spectrogram in case you are interested. [~,F,T,data] = spectrogram(...) data = 10*log10(data); I can plot the data ... (F),size(T),size(data),size(f),size(t) ans = 129 1 ans = 1 52 ans = 129 52 ans = 200 1 ans = 1 121
asked Apr 30 muktaa 34.6k points
0 votes
1 answer 17 views
Problem: I keep getting this error:error using griddedinterpolant the grid vectors must contain unique points.Please someone help me.
asked Apr 4 ashik 14.6k points
0 votes
1 answer 16 views
Program: please help to solve me... how to rig a character in unity
asked Mar 26 Ifra 37.2k points
0 votes
1 answer 22 views
Do I need to use C# Windows Application or can I use Console Applications? Do I only need to save the charts on a server?
asked Sep 17, 2020 Sofi55 1.1k points
0 votes
1 answer 318 views
Problem: I am trying to plot two vectors in MATLAB and it keeps giving me the error that error in plot vector must be same length. What to do? Some one please help.
asked Oct 10, 2020 Ahsan 1.8k points
0 votes
1 answer 78 views
Problem: You should not define a class field that is dependent upon the values of other class fields: A) in order to avoid having stale data B) because it is redundant C) because it should be defined in another class D) in order to keep it current
asked Aug 4, 2020 ArifulIslam 7.5k points
0 votes
1 answer 42 views
Problem: I want to define a variable in Matlab in terms of x. Please help.
asked Oct 10, 2020 Ahsan 1.8k points
0 votes
0 answers 3 views
Problem: I have written this codeing for this problem:- /** * Definition for a point. * class Point { * int x; * int y; * Point() { x = 0; y = 0; } * Point(int a, int b) { x = a; y = b; } * } */ public class Solution { public int maxPoints(Point[] ... O(n^3). I am trying to find is 2d plan not 3. And does there exist a better solution to this problem at better run time. I can't think of any.
asked Apr 26 nabin 4.6k points
0 votes
1 answer 17 views
Problem: i got error please anyone who help me please help non-singleton dimensions of the two input arrays must match each other.
asked Mar 17 Rohit kr 17.5k points
0 votes
0 answers 5 views
Problem: I was trying to solve Lorenz System in matlab by using the method of RK2 and RK4. I had a script for both of the methods, the problem now is how can converge the following y(1) = @(t,y) 10*(y(2)-y(1)); y(2) = @(t,y) y(1)*(28-y(3))-y(2); y(3) = @(t,y) y(1)*y(2)-8*y(3)/3; ... y1 = stepsize.*fcn(t(n),y(:,n)); y2 = stepsize.*fcn(t(n) + stepsize/2, y(:,n) + y1./2); y(:,n+1) = y(:,n) + y2; end
asked Apr 5 nabin shrestha 4.3k points