How to plot, when one parameter is inversely proportional to fifth power of other?

1 visualizzazione (ultimi 30 giorni)
Hi everybody, I am trying to plot a scatter plot such that parameter on y-axis (F) has inversely relation to the fifth power of parameter on x-axis (K). Problem is that when I plot the scatter plot then the “x-tick” and “x-ticklabel” does not coincide. What should I do to overcome this problem. The code and data is given below
x=[0.188,0.586,0.982,2.09,2.24,9.38,20.9,39.27,54];
f1=4.16*1.e-10*(0.188)^-5;
f2=4.16*1.e-10*(0.586)^-5;
f3=4.16*1.e-10*(0.982)^-5;
f4=4.16*1.e-10*(2.09)^-5;
f5=4.16*1.e-10*(2.24)^-5;
f6=4.16*1.e-10*(9.38)^-5;
f7=4.16*1.e-10*(20.9)^-5;
f8=4.16*1.e-10*(39.27)^-5;
f9=1*4.16*1.e-10*(54)^-5;
F=[f1,f2,f3,f4,f5,f6,f7,f8,f9];
scatter(x,log10(F),'b','*')
set(gca,'xtick',[1 2 3 4 5 6 7 8 9]);
set(gca,'xticklabel',{'0.188','0.586','0.982','2.09','2.24','9.38','20.9','39.27','54'});
ylabel('\fontsize{8}\fontname{Arial} log10(F) ')
xlabel('\fontsize{8}\fontname{Arial} K ')
set(gca,'FontSize',8);

Risposta accettata

Pawel Jastrzebski
Pawel Jastrzebski il 8 Gen 2018
Modificato: Pawel Jastrzebski il 8 Gen 2018
This line needs to be changed:
set(gca,'xtick',[1 2 3 4 5 6 7 8 9]);
See if the changed code below works for you:
x=[0.188,0.586,0.982,2.09,2.24,9.38,20.9,39.27,54];
xLabelText = num2cell(x);
f1=4.16*1.e-10*(0.188)^-5;
f2=4.16*1.e-10*(0.586)^-5;
f3=4.16*1.e-10*(0.982)^-5;
f4=4.16*1.e-10*(2.09)^-5;
f5=4.16*1.e-10*(2.24)^-5;
f6=4.16*1.e-10*(9.38)^-5;
f7=4.16*1.e-10*(20.9)^-5;
f8=4.16*1.e-10*(39.27)^-5;
f9=1*4.16*1.e-10*(54)^-5;
F=[f1,f2,f3,f4,f5,f6,f7,f8,f9];
scatter(x,log10(F),'b','*')
set(gca,...
'xtick',x,...
'xticklabel',xLabelText,...
'FontSize',8);
ylabel('\fontsize{8}\fontname{Arial} log10(F) ')
xlabel('\fontsize{8}\fontname{Arial} K ')
grid on

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by