How to smoothen the following plot in matlab?

조회 수: 1 (최근 30일)
marya
marya 2017년 5월 18일
답변: 10B 2017년 5월 26일
I used the following code to plot the figure below
function dydt = model (t,y)
dydt = zeros (size(y));
Ah=0.000051;Av=0.071;b1=0.071;b2=0.091;g=0.0035;
d1=0.0000043;d2=0.04;e1=0.001;w=0.11;
Sh=y(1);
Ih=y(2);
Rh=y(3);
Sv=y(4);
Iv=y(5);
Nh = Sh+Ih+Rh;
%The model
dydt(1) = Ah - b1*Iv*Sh/Nh +w*Rh - d1*Sh;
dydt(2) = b1*Iv*Sh/Nh - (g + e1 + d1)*Ih;
dydt(3) = g*Ih - (w +d1)*Rh;
dydt(4) = Av - b2*Ih*Sv/Nh - d2*Sv;
dydt(5) = b2*Ih*Sv/Nh - d2*Iv;
%The basic reproduction number for the model
R0 = sqrt((b1*b2*Av*d2)/(Ah*(d2^2)*(g + e1+ d1)));
disp(R0)
end
% plot
tspan = [0 10000];
y0 = [3600 1000 100 9600 400];
[t,y] = ode45(@model,tspan,y0);
plot(t,y(:,1),'b',t,y(:,2),'r',t,y(:,3),'g','Linewidth',3)
title('Plot of human population against time')
xlabel('Time(years)')
ylabel('Number of People')
legend('Susceptible ','Infectious','Recoverd' ,2)
As you can see the curves are not smooth enough. How can I smooth the curves further?
  댓글 수: 3
Tina
Tina 2017년 5월 18일
In what way the curves are not smooth enough? To me it seems only due to the resolution of the plot.
Guillaume
Guillaume 2017년 5월 18일
@KSSV, marya original formatting was very confusing as she'd conflated the ode function with the script that uses it. All the information was there. I've edited her post.
@Maria, I agree with Tina, the plots look very smooth, so you'll have to explain better what improvements you want.

댓글을 달려면 로그인하십시오.

채택된 답변

10B
10B 2017년 5월 26일
Hello,
I think the pixellation is just because of the resolution of the image, but if you want to smooth your data - use smooth!
HTH
10B.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by