Issue with contour plot due to different size
显示 更早的评论
Hello,
As cited above I want to have a contour plot, but the problem is the size of X and Z are different. as given below:
x0 = x;
t0 = Time(1:9:100);
[t1, x1] = meshgrid(t0, x0);
contourf(t1,x1,H0I0_Turbulence_cen2,1000,'edgecolor','none')
colormap(jet);
colorbar;
X = min(t0):(max(t0)-min(t0))/9:max(t0);
set(gca, 'xlim', [min(t0) max(t0)]);
set(gca, 'xtick', X);
xtickformat('%.2f');
xlabel('t','FontSize',24,'fontweight','bold');
Y = min(x0):(max(x0)-min(x0))/9:max(x0);
set(gca, 'ylim', [min(x0) max(x0)]);
set(gca, 'ytick', Y);
ytickformat('%.1f');
ytickformat('%.2f');
ylabel('x','FontSize',24,'fontweight','bold')
set(gca,'ycolor','k');
set(gcf,'color','w');
hold on
contour(t1,x1,H0I0_Turbulence_cen2,'k','ShowText','on')
grid on
hold off
ct = 0:(max(max(H0I0_Turbulence_cen2))-0)/10:max(max(H0I0_Turbulence_cen2));
c=colorbar('Ticks',ct);
clim([0 max(max(H0I0_Turbulence_cen2))]);
c.TickLabels = compose('%.2f',ct);
ylabel(c,'\itI_{cen}','FontSize',24, 'fontweight', 'bold');
Here, size(t1) = 100 x 12, size(x1) = 100x12,
and size(H0I0_Turbulence_cen2)=6x12
So size is differing by a large amount.
Thus I get the error as "Error using contourf
The size of X must match the size of Z or the number of columns of Z."
Is there any way to solve this issue and plot the contour?
3 个评论
DGM
2024-4-29
What is the spatial relationship between them?
Rahul
2024-4-29
That's what I'm asking you. Your X,Y grids are based off of:
x0 = x; % this creates 100 elements of YData
t0 = Time(1:9:100); % this creates 12 elements of XData
So the question is why the variable called "x" (which corresponds to y) has 100 elements when the Z data has 6. If there is some sort of interpolation or translation that needs to be done, where in the space of YData do the upper and lower rows of the Z data lie?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
