Meshgrid for logarithmic scales

39 ビュー (過去 30 日間)
David Koenig
David Koenig 2011 年 12 月 21 日
回答済み: Rishabh Gupta 2017 年 10 月 15 日
I would like to make 3-D plot using mesh in which one axis should be on a logarithmic scale. Is there a way to use meshgrid and mesh to do this?
Thanks.

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 12 月 21 日
Set the corresponding scale to 'log'
h = figure;
A = axes;
surf(magic(10));
set(A,'XScale','log')
The explanation is in:
docsearch axes properties
under xscale/yscale/zscale

その他の回答 (2 件)

Rishabh Gupta
Rishabh Gupta 2017 年 10 月 15 日
If you are using mesh command, just use the following:
Set(gca,'XScale','log');

Walter Roberson
Walter Roberson 2011 年 12 月 21 日
It is not supported to set the [XYZ]Scale to 'log' if you are using transparency. I do not recall at the moment which of the settings takes priority.
If any of your coordinates on the log scale are 0 or less, then those points will be ignored with [XYZ]Scale is 'log', and nothing will be drawn to those points (in particular, no interpolation of the adjacent points towards the axis limit will be done.)
As far as I recall at the moment, it is allowed to use mesh with an axis set to log scale.
Are you perhaps attempting to use meshgrid to create points that will show up as-if linearly spaced when the axis is set to log scale? If so, then yes, just use exp(ThePoints) or 10.^(ThePoints) as the corresponding meshgrid argument.
Are you perhaps attempting to use meshgrid to create points that will show up as-if spaced logarithmically when the axis is set to linear -- faking a log scale? If so, then yes, just use ln(ThePoints) or log10(ThePoints) as the corresponding meshgrid argument (and watch out for original points <= 0)
  1 件のコメント
David Koenig
David Koenig 2011 年 12 月 21 日
Thank you, Walter. I think I see what you are getting at but I am still having trouble.
I have a surface Z(x,y) where I want to plot the x-axis on a logarithmic scale, analogous to the case where I have a line z(x) and I want to use
semilogx(x,z)
So, back to the case of Z(x,y). If I use
[X.Y]=meshgrid(log10(x),y)
mesh(X,Y,Z)
I get a nice plot but...
I get numbers on the x-axis that are the logs of x. I want the x-axis to have numbers of x.
If I use
[X.Y]=meshgrid(10.^x,y)
mesh(X,Y,Z)
I get overflow because 10.^x goes to inf.
Do you have any suggestions?
Thanks.

サインインしてコメントする。

カテゴリ

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