How to plot inverse power in matlab?.

3 次查看(过去 30 天)
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);

请先登录,再进行评论。

采纳的回答

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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by