MATLAB Answers

How to plot a surf-plot with out data extrapolation?

조회 수: 6(최근 30일)
Philippe Corner
Philippe Corner 2020년 12월 3일
답변: Tarunbir Gambhir 2020년 12월 22일
I would like to plot the same surf plot but without extrapolating on areas where are not scatter data.
The following script generates the attached figure.
clc;clear all
load R.mat; %find it attached
load l1T.mat; %find it attached
figure()
x = R(:,2); y = R(:,3); z = R(:,4); c = R(:,5);
sc = (max(z)-min(z))/(max(y)-min(y));
y0 = mean(y);
x0 = mean(x);
y = (y-y0)*sc;
x = (x-x0)*sc;
yv = linspace(min(y), max(y), 50);
zv = linspace(min(z), max(z), 50);
[Y,Z] = meshgrid(yv, zv);
X = griddata(y,z,x,Y,Z,'cubic');
C = griddata(y,z,c,Y,Z,'cubic');
Y = Y/sc + y0;
X = X/sc + x0;
surf(X,Y,Z,'cdata',C)
hold on
scatter3(R(:,2),R(:,3),R(:,4),10,'filled','k')
hold on
plot3(l1T(:,1),l1T(:,2),l1T(:,3),'k','linewidth',2)
How can I get the same figure but cutted exactly on the highest Z position, which is represented by the black line and bounds the dots positions.

답변(1개)

Tarunbir Gambhir
Tarunbir Gambhir 2020년 12월 22일
If I understand correcty, you want to set limits to the axes containing your figure. I suggest you use axis function to do the same.
If this is not what you want, do explain further and attach the data files so that we can repliate the results on our end.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by