I getting an error (interp2 size). Can you help me ??
3 views (last 30 days)
Show older comments
??? Error using ==> interp2 at 147 The lengths of X and Y must match the size of Z.
??? Error in ==> Untitled55 at 12 mesh (xi,yi,interp2 (x,y,A,xi,yi, 'linear'));
% Code here:
clc;
clear all
clf;
colormap ('JET');
A = [-10,5,10;0.2,1,2;1,6,2];%%%%
% I am sure, this error is here...I did not understand. How can I do?
x = (-10:.5:10);
y = [0.98391 0.99116 0.99551 1.00565 0.99406 0.97377 0.99406 0.98391 0.98681 0.96797....
0.95348 0.92884 0.89986 0.90565 0.93174 0.96652 1.02304 1.08681 1.14188 1.13029....
1.1042 1.09986 1.09261 1.07087 1.06942 1.05928 1.06507 1.06797 1.05203 1.05493....
1.05348 1.07522 1.06217 1.07667 1.05203 1.05058 1.05638 1.06797 1.04333];
xi = linspace (min (x), max (x), 39);
yi = linspace (min (y), max (y), 5);
mesh (xi,yi,interp2 (x,y,A,xi,yi, 'linear'));
[x,y] = meshgrid (x,y);
hold on; plot3 (x(:),y(:),A(:),'b*'); hold off;
3 Comments
Answers (1)
Dishant Arora
on 23 Feb 2014
Edited: Dishant Arora
on 23 Feb 2014
A should have as many elements as length(x)*length(y) . A specifies values at those grid points.
1 Comment
Dishant Arora
on 23 Feb 2014
Erhan, you should ask your query here in comment box. for example go throgh the documentation of interp2
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!