필터 지우기
필터 지우기

Plotting 3D data set over x-y plane (x,y,z coordinates)

조회 수: 7 (최근 30일)
Paul
Paul 2013년 10월 16일
답변: Paul 2013년 10월 16일
Hi,
I have a set of (x,y,z) vectors where (x) and (y) are coordinates and (z) is the magnitude at that coordinate point. I have been trying to plot these to make a heatmap/contour type plot, but have not been able to get the correct results. My latest attempt goes like this:
if true
% XYZ = [busCoordsX, busCoordsY, busVolts];
[X,Y,Z] = meshgrid(busCoordsX, busCoordsY, busVolts);
vq = griddata(busCoordsX, busCoordsY, busVolts, XYZ, X, Y, Z);
figure; surf(X,Y,vq);
end
busCoordsX, busCoordsY and busVolts are 130x1 vectors (double).
The error I'm getting is:
Error using scatteredInterpolant The number of data point locations should equal the number of data point values.
Error in griddata>useScatteredInterp (line 188) F = scatteredInterpolant(inargs{1}(:),inargs{2}(:),inargs{3}(:), ...
Error in griddata (line 125) vq = useScatteredInterp(inputargs, numarg, method, 'none');
Error in plotVoltage3D (line 54) vq = griddata(busCoordsX, busCoordsY, busVolts, XYZ, X, Y, Z);
Please help!
Thanks.

답변 (2개)

Adam Filion
Adam Filion 2013년 10월 16일
편집: Adam Filion 2013년 10월 16일
Try:
F = scatteredInterpolant(busCoordsX,busCoordsY,busVolts);
[xx,yy]=meshgrid(busCoordsX,busCoordsY);
zz = F(xx,yy);
contour(xx,yy,zz)
surf(xx,yy,zz)

Paul
Paul 2013년 10월 16일
Hi Adam,
Thanks for the quick response. The code does mostly what I'm looking for, however, it includes a bunch of lines and doesn't quite get the plot I'm looking for. Ultimately, I'd like a scatter plot of the (x,y) points and the voltage magnitudes overlayed with a surface plot. The attached pictures probably makes more sense.
Again, thanks for your help!

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by