Surface plot ignores points when using log scale

3 次查看(过去 30 天)
I'm plotting data using surf and find that some data points seem to be ignored when I have the z-axis in log scale versus linear. In the code for example, the point at G(9,7) clearly shows up on the linear plot but there is a blank square when in log mode. Switching between log and linear mode on the plot with the "flat" orientation shows points disappearing when going to log.
I've tried using NaN instead of zero but still don't get the results I want. Using Mesh seems to do the same thing.

采纳的回答

David Goodmanson
David Goodmanson 2016-10-10
编辑:David Goodmanson 2016-10-10
Hi Daniel, You are of course going to get some infs in your log plot since log(0) = -inf. Take a look at
x = 1:10;
y = 1:10;
[xx yy] = meshgrid(x,y);
zz = xx+yy;
figure(1); surf(xx,yy,zz)
zz(5,6) = inf; figure(2); surf(xx,yy,zz)
zz(5,6) = nan; figure(3); surf(xx,yy,zz)
Matlab cuts out tiles that have a corner value of inf or NaN.
So, for the log plot you could replace the zeros with a value like 1e-6 or whatever works. For plots that really do contain inf, I don't know if there is anything you could do. Maybe somebody else will. At least if you want to make a 3d model of a house, it will be easy to do the windows.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by