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

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.

 Accepted 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')

2 Comments

Great, this solved it all, just now need to find out how to set the x,y,z values right to show it good. like to show B from 10-5000, f from 100-300000 and then z from 0 -5000. And then find a way to get the colours displayed in this correc, first atempt was only showing black.. But ths ws a realy good imrovment after 12 houers of errors.. thanks a lot for the support Star Strider
As always, my pleasure.
Experiment with this code to customise your axis labels:
figure(1)
mesh(f,B,Loss)
xtix = get(gca, 'XTick');
ytix = get(gca, 'YTick');
xtlbl = regexp(sprintf('%.0f\n', xtix), '\n', 'split');
ytlbl = regexp(sprintf('%.0f\n', ytix), '\n', 'split');
set(gca, 'XScale','log', 'YScale','log')
set(gca, 'XTick',xtix, 'XTickLabel',xtlbl(1:end-1), 'XTickLabelRotation',-30)
set(gca, 'YTick',ytix, 'YTickLabel',ytlbl(1:end-1), 'YTickLabelRotation',+30)
xlabel('f')
ylabel('B')
zlabel('Loss')
axis tight
I am not certain what you want, however this should get you started. See the documentation on Axis Properties (link) for more information.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!