Curve fitting... Matrix dimensions do not agree

2 Ansichten (letzte 30 Tage)
derek lukasik
derek lukasik am 27 Okt. 2017
Bearbeitet: Walter Roberson am 27 Okt. 2017
I need to fit the non-linear data to the curve and use polyfit to obtain Ea and A. I believe I have Ea = 35.42. I'm super tired can someone please explain what I am doing wrong here? The matrix dimensions do not agree and I am having a hard time seeing the variable dimensions in my gui.
function prob3()
close all
T = [773 786 797 810 810 820 834];
K = [1.63 2.95 4.19 8.13 8.19 14.9 22.2];
R = 8314;
% Your work goes here ...
figure
plot(T,K,'k.','markersize',50);
daspect([1 1 1])
set(gca,'fontsize',18);
axis([770 840 0 50]);
set(gca,'dataaspectratiomode','auto');
% k = Aexp(-Ea/RT)
% log(k) = log(A) + log(exp(-Ea/RT))
acoeffs = polyfit(log(T), log(K),1)
A = exp(acoeffs(2))
Ea = acoeffs(1)
xl = linspace(770, 10, 840);
kl = A.*exp(Ea.*xl./R.*T);
hold on
figure
plot(xl,kl,'r')
% Be sure to include :
% -- Plots of data points
% -- Best fit curve to your datat
% -- axis labels
% -- title
% -- Legend.
write_file([A,Ea],'reactioncoeffs.out');
end

Antworten (1)

KSSV
KSSV am 27 Okt. 2017
Lengths of xl and T should be same for multiplication.
Replace line:
xl = linspace(770, 10, 840);
with
xl = linspace(770, 10, length(T));

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by