Data fitting weibull and integration
Afficher commentaires plus anciens
Hi all, first of all let me say that i'm a bit inexperienced regrading programming and Matlab. I have made a m file with a bit of code that tries to fit a weibull distribution function to some data from a excel file. this part is done by the code but i also want to do a definite integral on that function multiplied by x but i always get the same error, says that cannot find explicit integral... i don't know if the problem is because of the function hand le or other thing... any suggestions?
CODE:
clc
% Vectors (x, fi) to create histogram with the experimental data for length
%%#1
% Go to excel spreadsheet and retrieve the data for x, fi, vectors
fi = xlsread('C:\Users\Nuno\Documents\MATLAB\dados_raiz_working.xlsx','Dados raiz','f4:f42');
x = xlsread('C:\Users\Nuno\Documents\MATLAB\dados_raiz_working.xlsx','Dados raiz','b4:b42');
Lmean=xlsread('C:\Users\Nuno\Documents\MATLAB\dados_raiz_working.xlsx','Weibull','o7')
%bar graph
bar(x,fi)
fi=fi';
x=x';
%%#2
% Weibull function
modelFun = @(p,x) p(3) .* (x ./ p(1)).^(p(2)-1) .* exp(-(x ./ p(1)).^p(2));
startingVals = [2.6057 0.67657 1];
coefEsts = nlinfit(x', fi', modelFun, startingVals)
xgrid = x;
%%#3
%Writes on excel spreadsheet the data obtained from weibull distribuiton
write_column_excel=xlswrite('C:\Users\Nuno\Documents\MATLAB\dados_raiz_working.xlsx',modelFun(coefEsts, xgrid)', 'Weibull', 'D3');
%%#4
% line graph
line(xgrid, modelFun(coefEsts, xgrid), 'Color','red','LineWidth',2.5)
title('\fontsize{14}Histograma com distribuição de Weibull')
xlabel('\fontsize{12}Comprimentos(mm)');
ylabel('\fontsize{12}Frequência (%)')
h = legend('Dados Raiz','Distribuição Weibull',1);
set(h,'Interpreter','none')
text(1.28,6,[{'\bf \fontsize{12}Goodness of fit'}])
text(1.3,5,['SSE=19.65'])
text(1.3,4.4,['R^2=0.94'])
text(1.3,3.8,['RMSE=0.7387'])
hold on
%%#5
%In here i try to determine a specific coeficient that is obtained by definite integration between 0 and inf of the weibull function multiplied by "x" and (1/Lmean) (PROBLEM!!).
a=coefEsts(1); %Coeficientes dados pelo método de regressão linear
b=coefEsts(2); %na célula 3
c=coefEsts(3);
syms x
modelFun = @(x) c .* (x ./a).^(b-1) .* exp(-(x ./ a).^b);
Coef_ajust_length=eval(int(modelFun(x)*x*(1/Lmean), x, 0, inf));
1 commentaire
Nuno
le 19 Avr 2011
Réponse acceptée
Plus de réponses (2)
Catégories
En savoir plus sur Weibull Distribution dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!