Suppose I only have 35 data points, it is very expensive to run.
x=rand(5,7)
figure
imagesc(x)
axisx=[11 12 13 14 15 16 17]
axisy=[10 20 30 40 50]
Is there any way to present them smoother, using imagesc gives too pixel. Is there any interpolation?
and display the axis with my axisx and axisy

 採用された回答

Davide Masiello
Davide Masiello 2022 年 11 月 2 日

1 投票

x=rand(5,7)
x = 5×7
0.2207 0.4751 0.9818 0.6898 0.8489 0.7640 0.3894 0.1370 0.3264 0.7110 0.4195 0.6313 0.4999 0.0168 0.9267 0.9988 0.6922 0.3023 0.1398 0.5576 0.8856 0.2924 0.5511 0.0081 0.9578 0.6766 0.4339 0.1714 0.5717 0.5432 0.3209 0.2490 0.3414 0.1640 0.6649
figure
contourf(x,'LineColor','none')
shading interp
axis equal off

4 件のコメント

Miraboreasu
Miraboreasu 2022 年 11 月 2 日
編集済み: Miraboreasu 2022 年 11 月 2 日
Is there a way to eliminate the lines? and sorry I add about the axis displacement
William Rose
William Rose 2022 年 11 月 2 日
編集済み: William Rose 2022 年 11 月 2 日
Z=2*rand(5,7);
[X,Y]=meshgrid(0:6,0:4); %locations of the known values
surf(X,Y,Z,'EdgeColor','None');
axis equal
Now compute interpolated values and plot the interpolated values:
[Xi,Yi]=meshgrid(0:.2:6,0:.2:4); %locations for interpolation
Zi=interp2(X,Y,Z,Xi,Yi);
surf(Xi,Yi,Zi,'EdgeColor','None');
axis equal
This surface is more filled in and as a result the coloring looks better. In the example above, the inteprolaiton was linear, by default. You can use smoother interpolaiton to get an even smoother plot. See below:
Zi2=interp2(X,Y,Z,Xi,Yi,'makima');
surf(Xi,Yi,Zi2,'EdgeColor','None');
axis equal
Looks smooth. YOu can also plot this as floows:
figure
contourf(Zi2,'LineColor','none')
shading interp
axis equal off
Not bad.
Miraboreasu
Miraboreasu 2022 年 11 月 2 日
編集済み: Miraboreasu 2022 年 11 月 2 日
Thank you, I think I need to rephase my quesiton, but I don't if I need to post a new thread, I will ask here first.
So for this matrix,
x=rand(5,7)
each row is one variable changing
axisx=[11 12 13 14 15 16 17]
each column is another variable changing
axisy=[10 20 30 40 50]
the value of the matrix like x(1,2) is what I want to show in colorbar
What is the best way to present them? with axis
Davide Masiello
Davide Masiello 2022 年 11 月 2 日
編集済み: Davide Masiello 2022 年 11 月 2 日
axisx = [11 12 13 14 15 16 17];
axisy = [10 20 30 40 50];
[x,y] = meshgrid(axisx,axisy);
z = rand(5,7);
[x_new,y_new] = meshgrid(linspace(axisx(1),axisx(end),100),linspace(axisy(1),axisy(end),100));
z_new = interp2(x,y,z,x_new,y_new);
contourf(x_new,y_new,z_new,linspace(min(z(:)),max(z(:)),100),'LineColor','none')
shading interp
colorbar
xlabel('x axis')
ylabel('y axis')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

製品

リリース

R2022a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by