# To fit power law

7 visualizzazioni (ultimi 30 giorni)
aneps il 16 Giu 2014
Modificato: John Kelly il 17 Dic 2015
I want to fit power law on my data (Data attached here - Data.txt file). I have the following code:
ft=fittype(@(m,b,x)b*x.^m);
f = fit(A(:,1),A(:,2),ft)
figure
plot(f,':g',A(:,1),A(:,2),':b')
But this is not fitting my data with the power law. Could you please check what is the problem? I guess, my data is not starting from zero. I think, I have to normalize it(I am not sure). When I use fitoptions to normalize, it is not working!
I tried to fit by taking log on both sides because y=A*x^m log(y)=log(A)+m*log(x)
ft=fittype(@(a,m,x)log(a)+m*log(x));
[f gof] = fit(A(:,1),log(A(:,2)),ft)
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Miroslav Balda il 16 Giu 2014
If you plot the given vectors by the statement semilogy(A(:,1),A(:,2),':o'),you observe that the pure power function does not fit well the measured data, because the plotted points are not on a straight line (in semilogy axes). It would need more complicated function. Mira
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Exploration and Visualization in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by