Borrar filtros
Borrar filtros

How to plot inverse power in matlab?.

3 visualizaciones (últimos 30 días)
Safi ullah
Safi ullah el 8 de En. de 2018
Comentada: Safi ullah el 9 de En. de 2018
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 comentarios
the cyclist
the cyclist el 8 de En. de 2018
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 el 9 de En. de 2018
@ the cyclist thanks

Iniciar sesión para comentar.

Respuesta aceptada

the cyclist
the cyclist el 9 de En. de 2018
Editada: the cyclist el 9 de En. de 2018

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.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by