Surface plot ignores points when using log scale

7 ビュー (過去 30 日間)
Daniel
Daniel 2016 年 10 月 10 日
編集済み: David Goodmanson 2016 年 10 月 10 日
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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by