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)

 Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 11 Nov. 2020
Bearbeitet: Ameer Hamza am 11 Nov. 2020

0 Stimmen

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 Kommentare

Delna Johnson
Delna Johnson am 12 Nov. 2020
But I want my t value to vary from 1:1000 Is that possible?
Ameer Hamza
Ameer Hamza am 12 Nov. 2020
You want to get the value of integral with all those end-points?
Delna Johnson
Delna Johnson am 12 Nov. 2020
Yes, is that possible?
Delna Johnson
Delna Johnson am 12 Nov. 2020
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 am 12 Nov. 2020
Thank you so much.
Ameer Hamza
Ameer Hamza am 12 Nov. 2020
I am glad to be of help!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by