alpha1=0.1;
eps=0.05;
gamma=0.34;
x1=0.5;
x2=0.8;
bheta1=0.11;
k1=0.65;
f=@(x1)[(alpha1-eps*gamma)x1-(alpha1/k1)(x1)^2-bheta1*x1*x2]
t=1:1000
h=integral(f,0,t)

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 11일
편집: Ameer Hamza 2020년 11월 11일

0 개 추천

MATLAB does not have an implicit multiplication. You need to use * operator
f=@(x1)[(alpha1-eps*gamma)*x1-(alpha1/k1)*(x1).^2-bheta1*x1*x2];
% ^ here and ^ here
Also, It is better to vectorize the integrand; therefore, I used element-wise exponent (.^) in the expression. Also, note that 3rd input to integral() must be a scalar.

댓글 수: 7

Delna Johnson
Delna Johnson 2020년 11월 12일
But I want my t value to vary from 1:1000 Is that possible?
Ameer Hamza
Ameer Hamza 2020년 11월 12일
You want to get the value of integral with all those end-points?
Delna Johnson
Delna Johnson 2020년 11월 12일
Yes, is that possible?
Delna Johnson
Delna Johnson 2020년 11월 12일
Because I want to plot graph with those values.
You can do it like this
alpha1=0.1;
eps=0.05;
gamma=0.34;
x1=0.5;
x2=0.8;
bheta1=0.11;
k1=0.65;
f=@(x1)(alpha1-eps*gamma)*x1-(alpha1/k1)*(x1).^2-bheta1*x1*x2;
t = 1:1000;
h = zeros(size(t));
for i = 1:numel(h)
h(i) = integral(f, 0, t(i));
end
plot(t, h)
Delna Johnson
Delna Johnson 2020년 11월 12일
Thank you so much.
Ameer Hamza
Ameer Hamza 2020년 11월 12일
I am glad to be of help!!!

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2020년 11월 11일

댓글:

2020년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by