i found that the a0 vlues will be the same value as the exponential e(1), which is why that causes alpha to be 0, but how to fix this probleM?
my graph won't show the exponential graph as the alpha value is 0, can someone help fix this problem?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
%a
cockrach=importdata('cockroach_population.xlsx');
num_cockrach=cockrach.data;
days=num_cockrach(:,1);
cockraches=num_cockrach(:,2);
%b
ylin=cockraches;
xlin=log(days);
[a0,a1,r2] = linreg(xlin,ylin);
p=polyfit(days,cockraches,2);
alpha=(exp(1)).^a0;
Beta=a1;
text1=sprintf('parabola-cockraches rate: cockraches= %.2fx^2+%.2fx+%.2f',p);
%c
exponential_curve= alpha.*exp(1).^(Beta.*days);
text2=sprintf('exponential-cockraches rate: cockraches= %.2fe^%.2fx\n',alpha, Beta);
figure
plot(days,cockraches,'b.');
hold on
plot(days,polyval(p,days),'r-','LineWidth',3);
plot(days,exponential_curve,'g-','LineWidth',3)
title('numbers of cockraches vs times(days)');
xlabel('cockraches');
ylabel('days');
legend('unlinearised',text1,text2)
4 Kommentare
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!