2D and 3D graphs
5 次查看(过去 30 天)
显示 更早的评论
I'm looking for a way to draw the attached data (X,Y,S) as 2D graph with S being the color or as 3D graph that includes (X,Y,S) I have tried the mesh and surf. however, the plot doesn't give much information and the resulted shape is wrong, since the ultimate shape should looks like ( + ). Can anyone please help me with this?
2 个评论
Jan
2020-10-28
Please make it as easy as possible to answer your question. Post the code you have already, such that the readers do not have to guess, which code is producing, what you think is wrong.
采纳的回答
KSSV
2020-10-28
Try this:
num = xlsread("Test1.xlsx") ;
[r,c] = size(num');
n = r/9;
% Arrange the data
A = permute(reshape(num,[c,r/n,n]),[2,1,3]);
A = permute(A,[2 1 3]) ;
% get x,y,s
x = squeeze(A(:,2,:)) ;
y = squeeze(A(:,3,:)) ;
s = squeeze(A(:,6,:)) ;
% do inteprolation and convert to grid
m = 100 ; n = 100 ;
xi = linspace(min(x(:)),max(x(:)),m) ;
yi = linspace(min(y(:)),max(y(:)),n) ;
[X,Y] = meshgrid(xi,yi) ;
S = griddata(x,y,s,X,Y) ;
% Make exact plus sign
idx = boundary(x(:),y(:)) ;
bx = x(idx) ; by = y(idx) ;
idx = inpolygon(X,Y,bx,by) ;
S(~idx) = NaN ;
% plot
pcolor(X,Y,S)
shading interp
colorbar
4 个评论
KSSV
2020-10-29
Read about caxis. You can limit the color values here.....but it will effect the complete plot.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!