Interpolate data to present with limited size of data

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

 채택된 답변

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
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.
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
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 Exchange에서 Line Plots에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2022년 11월 2일

편집:

2022년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by