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)

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 11 de Nov. de 2020
Editada: Ameer Hamza el 11 de Nov. de 2020

0 votos

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 comentarios

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 11 de Nov. de 2020

Comentada:

el 12 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by