How do I plot points on a contour?

39 次查看(过去 30 天)
data = readtable('Sample.xlsx');
ux1 = unique(data.x1);
nx1 = length(ux1);
X1 = reshape(data.x1, [], nx1);
X2 = reshape(data.x2, [], nx1);
Y = reshape(data.Y, [], nx1);
K = reshape(data.Kriging, [], nx1);
kerr = Y - K;
contourf(X1, X2, abs(kerr), 20);
colormap turbo
xlabel('x1')
ylabel('x2')
title('Sample(n=20)')
colorbar
caxis([0 1.5])
I want to mark the kriging.xlsx file on the contour.
Please let me know. Thank you

采纳的回答

Star Strider
Star Strider 2021-6-8
I am not certain what result you want.
I plotted it with scatter3, however if the intent os to have lines connecting the points, use plot3.
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/645250/Sample.xlsx');
krin = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/645255/kriging.xlsx');
ux1 = unique(data.x1);
nx1 = length(ux1);
X1 = reshape(data.x1, [], nx1);
X2 = reshape(data.x2, [], nx1);
Y = reshape(data.Y, [], nx1);
K = reshape(data.Kriging, [], nx1);
kerr = Y - K;
figure
contourf(X1, X2, abs(kerr), 20)
hold on
scatter3(krin.x1, krin.x2, krin.kriging, 50, 'r', 'filled')
hold off
colormap turbo
xlabel('x1')
ylabel('x2')
title('Sample(n=20)')
colorbar
caxis([0 1.5])
.

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by