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 2 2 2 1 1 5 5 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 7 1 1 7 7 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 9 1 1 9 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 9 1 1 9 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 1 1 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 1 1 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 1 1 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1];
Xq=1:.05:41;
Yq=1:.05:20;
[Xq,Yq]=meshgrid(Xq,Yq);
Vq=interp2(X,Y,V,Xq,Yq,'cubic');
surf(Xq,Yq,Vq)
title('NBA Injuries 2019 Season')
ylabel('Height')
xlabel('Width')
colorbar
I am trying to create a model of the human body using MATLAB. It is supposed to illustrate the most common injuries sustained by NBA players during the season. When I run my code I recieve 3 error messages. They are the following:
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);
I am terrible at MATLAB so I have no idea what any of this means. Any help is appreciated.

采纳的回答

Matt J
Matt J 2019-12-4
You have 20 Y samples, but your V has 21 rows.
>> whos X Y V
Name Size Bytes Class Attributes
V 21x41 6888 double
X 1x41 328 double
Y 1x20 160 double

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by