Borrar filtros
Borrar filtros

I am trying to smooth out this graph for an assignment and the code i have entered is exactly what the teacher has showed us, but mine comes up with errors that I don't understand. Can someone help me understand these errors as well as fix my code?

3 visualizaciones (últimos 30 días)
x = 0:1:10;
y = 0:1:10;
z = [0 0 0 4 4 4 4 3 3 3; 0 4 14 28 33 36 48 35 15 3; 0 9 30 47 51 47 43 45 30 3; 4 23 37 59 62 57 56 45 40 19; 4 30 48 61 63 58 61 58 44 19; 4 24 43 59 63 60 58 55 46 19; 4 21 35 50 58 58 55 43 38 19; 0 13 22 29 39 46 43 36 32 4; 0 10 11 17 23 28 28 29 28 4; 0 0 0 9 9 9 9 4 4 4];
xi = 0:.5:10;
yi = 0:.5:10;
[xi,yi] = meshgrid(xi,yi);
zc = interp2(x,y,z,xi,yi,'cubic');
surf(xi,yi,zc);
xlabel('Catcher Viewpoint');
ylabel('RHB Viewpoint');
zlabel('Swing Percentage');
title('Mookie Betts Swing% in 2018');
text(3,5,75, 'Middle of the Strikezone');
These are the errors:
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)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in matlabproj (line 7)
zc = interp2(x,y,z,xi,yi,'cubic');
  3 comentarios
Jared Turgeon
Jared Turgeon el 2 de Dic. de 2019
z is 10 and x is 11, how is this so?
I looked up fencepost error and understand that, but how would I go aabout fixing that in this scenario?

Iniciar sesión para comentar.

Respuestas (1)

Marcel Kreuzberg
Marcel Kreuzberg el 3 de Dic. de 2019
try with
x = 1:1:10;
y = 1:1:10;

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by