my graph won’t show the exponential graph as the alpha value is 0, can someone help fix this problem?
%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^%.2fxn’,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)%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^%.2fxn’,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) %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^%.2fxn’,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) exponential curve, nonlinear, linear MATLAB Answers — New Questions