Contour Plot gives error
조회 수: 7 (최근 30일)
이전 댓글 표시
figure
x = ICE_m_f_dot_map_temp_w; % 1*140 array of values
y = ICE_m_f_dot_map_temp_T; % 1*140 array of values
[X,Y]=meshgrid(x,y);
z = ICE_m_f_dot_map_temp; % 1*140 array of values
contour3(X,Y,z)
With the above code I am trying to plot contours but I recieve this error.
Error using contour3 (line 44)
Z must be at least a 2x2 matrix.
Error in ME7384AU21_Fahim_HW2 (line 97)
contour3(X,Y,z)
댓글 수: 0
채택된 답변
Walter Roberson
2021년 9월 25일
N = 200; %grid refinement
x = ICE_m_f_dot_map_temp_w; % 1*140 array of values
y = ICE_m_f_dot_map_temp_T; % 1*140 array of values
z = ICE_m_f_dot_map_temp; % 1*140 array of values
minx = min(x); maxx = max(x);
miny = min(y); maxy = max(y);
[X, Y] = meshgrid(linspace(minx, maxx, N), linspace(miny, maxy, N));
F = scatteredInterpolant(x(:), y(:), z(:));
Z = F(X, Y);
contour3(X, Y, Z);
댓글 수: 2
Walter Roberson
2021년 9월 25일
Your original code uses contour3 which is for 3d representation. If you want 2d then use contour() or contourf instead.
추가 답변 (1개)
KSSV
2021년 9월 25일
You cannot use contour with column data. You can use scatter to plot data or if your data is gridded consider using griddata or reshaping the data as shown in the blow link:
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!