how to perform a polyfit on semilog plot?

11 visualizzazioni (ultimi 30 giorni)
hi all. i have these two set of data, 'FOE' and 'Nc'. i want to plot FOE vs Nc in semilog plot (Nc placed on x axis increasingly and log scale, FOE on y axis, increasingly). how can i use polyfit command to pass a first order line from this semi-logarithmic graph and obtain slope and interceptof the fitted line. thanks in advance for all the advice you provide.

Risposta accettata

Star Strider
Star Strider il 12 Nov 2018
Try this:
FOE=[0.000743 0.000747 0.000747 0.000746 0.000746 0.000744 0.000744 0.000743 0.00065 0.00065...
0.000648 0.000648 0.000646 0.000646 0.000644 0.000644 0.000252 0.000252 0.000251 0.000251 0.000251...
0.000251 0.00025 0.00025 0.000219 0.000219 0.000219 0.000219 0.000218 0.000218 0.000217 0.000217];
Nc=[3.76e-7 8.97e-8 5.09e-8 3.55e-8 2.73e-8 2.22e-8 1.87e-8 1.61e-8 1.42e-8 1.26e-8 1.14e-8 1.04e-8 9.6e-9...
8.8e-9 8.2e-9 7.7e-9 7.2e-9 6.8e-9 6.4e-9 6.1e-9 5.8e-9 5.5e-9 5.3e-9 5.1e-9 4.8e-9 4.7e-9 4.5e-9 4.3e-9...
4.2e-9 4e-9 3.9e-9 3.8e-9];
B = polyfit(log(Nc), FOE, 1);
fitFOE = polyval(B,log(Nc));
Slope = B(1);
Intercept = B(2);
figure
semilogx(Nc, FOE, '*', Nc, fitFOE,'-')
grid

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by