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

2 ビュー (過去 30 日間)
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);

採用された回答

Pawel Jastrzebski
Pawel Jastrzebski 2018 年 1 月 8 日
編集済み: Pawel Jastrzebski 2018 年 1 月 8 日
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
  2 件のコメント
Safi ullah
Safi ullah 2018 年 1 月 8 日
@ Pawel Jastrzebski, it works thanks
Pawel Jastrzebski
Pawel Jastrzebski 2018 年 1 月 8 日
Also, your F vector can be specified as:
x=[0.188,0.586,0.982,2.09,2.24,9.38,20.9,39.27,54];
F = 4.16*1.e-10*x.^-5;

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by