フィルターのクリア

How to plot inverse power in matlab?.

3 ビュー (過去 30 日間)
Safi ullah
Safi ullah 2018 年 1 月 8 日
コメント済み: Safi ullah 2018 年 1 月 9 日
Hi everybody, I have the following data and code such that the parameter on y-axis (Y) has inversely relation to the fifth power of parameter on x-axis (X).
X=[0.188,0.586,0.982,2.09,2.24,9.38,20.9,39.27,54];
a1=4.16*1.e-10*(0.188).^-5;
a2=4.16*1.e-10*(0.586).^-5;
a3=4.16*1.e-10*(0.982).^-5;
a4=4.16*1.e-10*(2.09).^-5;
a5=4.16*1.e-10*(2.24).^-5;
a6=4.16*1.e-10*(9.38).^-5;
a7=4.16*1.e-10*(20.9).^-5;
a8=4.16*1.e-10*(39.27).^-5;
a9=1*4.16*1.e-10*(54).^-5;
Y=[a1,a2,a3,a4,a5,a6,a7,a8,a9];
plot(X,log10(Y),'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} Y ')
xlabel('\fontsize{8}\fontname{Arial} X ')
set(gca,'FontSize',8);
Also consider the below figure, and focus on x-ticks from 1 to 10 and from 10 to 100. As they are not equally spaced. I have also given the task to make fig from the given data and due to inverse relation of fifth power also arrange the x-axis. Now i do not understand that it will be spaced differently by default or by some logic,and does it is due the inverse relation of fifth power or whatever. any guidance will be appreciated. Noted with my given data we will have only one curve, thanks.
  2 件のコメント
the cyclist
the cyclist 2018 年 1 月 8 日
I don't have a solution for your issue, but here is a simplification of your code:
X = [0.188,0.586,0.982,2.09,2.24,9.38,20.9,39.27,54];
Y = 4.16e-10 * X.^(-5);
figure
plot(X,log10(Y),'b')
set(gca,'xtick',1:9);
set(gca,'xticklabel',X);%
ylabel('\fontsize{8}\fontname{Arial} Y ')
xlabel('\fontsize{8}\fontname{Arial} X ')
set(gca,'FontSize',8);
Safi ullah
Safi ullah 2018 年 1 月 9 日
@ the cyclist thanks

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

採用された回答

the cyclist
the cyclist 2018 年 1 月 9 日
編集済み: the cyclist 2018 年 1 月 9 日

You can get what I think you want using the semilogx plotting function, which makes the x-axis logarithmic. For example,

X = [0.188,0.586,0.982,2.09,2.24,9.38,20.9,39.27,54];
Y = 4.16e-10 * X.^(-5);
figure
semilogx(X,log10(Y),'b') 
ylabel('\fontsize{8}\fontname{Arial} Y ')
xlabel('\fontsize{8}\fontname{Arial} X ')
set(gca,'FontSize',8);

I removed the code you used to set the x-ticks and labels, because the values did not match the tick locations, which seemed odd to me.

You could also consider the loglog function for plotting, which will make both x- and y-axis logarithmic.

  1 件のコメント
Safi ullah
Safi ullah 2018 年 1 月 9 日
it works well, @ the cyclist thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by