How to plot inverse power in matlab?.

조회 수: 2 (최근 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 CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by