MATLAB: 3D plott whit log scale on x and y and divide inside the plot base

3d plots logMATLAB

Hi, I try to make this formula plotted in 3D to visualice something for a traning i should hold.
a=7.89e9; b=7.11e8; c=8.98e6; d=2.85e-14; f=linspace (1000,300000,31); B=linspace (1,4000,31); [X,Y]=meshgrid(f, B); Loss=(f/((a/B.^3)+(b/B.^2.3)+(c/B.^1.65)))+(d*B.^2*f.^2); mesh(f,B,Loss); surfe(f,B,Loss);
And this wont work, have tried a lot of things and noe progress. I se this is related to singular or division inside the formular, but i cant understand why this docent work. Trided this on Graphing calculator and then i get some out, but the presentation and log scale is not working on that so fare either. So i like to find a way to do this in Matlab as this is more convinient and powerfull for the future.

Best Answer

You created ‘X’ and ‘Y’ (corresponding to ‘f’ and ‘B’) correctly. You need to completely vectorize the ‘Loss’ calculation, and use them in it. Use a set call to set the axis scales.
Loss=(X./((a./Y.^3)+(b./Y.^2.3)+(c./Y.^1.65)))+(d*Y.^2.*X.^2);
figure(1)
mesh(f,B,Loss)
set(gca, 'XScale','log', 'YScale','log')
figure(2)
surf(f,B,Loss)
set(gca, 'XScale','log', 'YScale','log')