plot in logarithmic scale
30 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ELISABETTA BILLOTTA
am 12 Jan. 2022
Kommentiert: Star Strider
am 12 Jan. 2022
can someone tell me how in a 3d graph I can plot linearly the X and Y axis, while the Z axis (ZZ in this case) to plot it in logarithmic scale?
the command I use is contourf(XX,YY,ZZ,900,'linecolor','none').
thankss
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Jan. 2022
The contourf function plots a plane, not a surface.
To plot logarithmic contours of the ‘Z’ matrix, it will be necessary to calculate the logarithm of the matrix.
Z = randn(10) % Create Matrix
figure
contourf(Z)
colormap(turbo(10))
colorbar
title('$Original\ Z$', 'Interpreter','latex')
figure
contourf(log(abs(Z))) % Logarithms Of The Absolute Values
colormap(turbo(10))
colorbar
title('$log(|Z|)$', 'Interpreter','latex')
Zs = Z;
Zs(Zs<=0) = NaN; % 'NaN' Values Do Not Plot, log(NaN)= NaN
figure
contourf(Zs)
colormap(turbo(10))
colorbar
title('$log(Z > 0)$', 'Interpreter','latex')
.
2 Kommentare
Star Strider
am 12 Jan. 2022
I can probably make it work if I have your data and the relevant part of the code.
Using synthetic data —
x = 0:9;
y = 4:13;
z = randn(10);
figure
contourf(x, y, log(abs(z)))
colormap(turbo(10))
colorbar
So it definitely can work with linear ‘x’ and ‘y’ vectors (or matrices created from them using ndgrid or meshgrid).
.
Weitere Antworten (1)
Simon Chan
am 12 Jan. 2022
I think you may need to use function contour3.
Then you can set the Z-axis scale to log by
set(gca,'ZScale','log')
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!