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.
Ameer Hamza
Ameer Hamza 2020 年 11 月 12 日
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 についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by