Undefined function 'int' for input arguments of type 'double'.

syms x S1(x) E1(x) I1(x) R1(x) h1 h2 h3 h4 C1 C2 C3 C4
b = 0.001; w = 0.01; g = 0.02; NS = 497; NE = 1; NI = 1; NR = 1;
EQ = [ diff(S1,x) == 0, diff(E1,x) == 0, diff(I1,x) == 0, diff(R1,x) == 0 ];
SN = dsolve(EQ); fS1 = SN.S1; fE1 = SN.E1; fI1 = SN.I1; fR1 = SN.R1;
S(1) = NS; E(1) = NE; I(1) = NI; R(1) = NR;
for m = 2 : 7
for k = 1 : m - 1
S(m) = h1 * ( int( diff(S(m-1)) + b * S(k) * I(m-k) ));
E(m) = h2 * ( int( diff(E(m-1)) - b * S(k) * I(m-k) + w * E(k) ));
I(m) = h3 * ( int( diff(I(m-1)) - w * E(k) + g * I(k) ));
R(m) = h4 * ( int( diff(R(m-1)) + g * I(k) ));
end
end
SA = fS1 + S(1) + S(2) + S(3) + S(4) + S(5) + S(6) + S(7);
hS = subs(SA,h1,-1:0.25:1); figure(1),fplot(hS,[0 5])

6 Comments

You try to integrate (int) a number instead of a symbolic expression. That doesn't make sense.
First iteration is a number. If we integrate w.r.t. 'x' that could be a function of 'x' .
Then after all other iterations are functions of 'x'.
Then define S, E, l and R as syms arrays.
And add the integration variable in the int command:
syms S [2,1]
syms x
S(1) = 0.2;
S(2) = int(S(1),x)
S = 
Same in the diff command.
After Modifying
S(m) = h1 * ( int( diff(S(m-1),x) + b * S(k) * I(m-k),x ));
E(m) = h2 * ( int( diff(E(m-1),x) - b * S(k) * I(m-k) + w * E(k),x ));
I(m) = h3 * ( int( diff(I(m-1),x) - w * E(k) + g * I(k),x ));
R(m) = h4 * ( int( diff(R(m-1),x) + g * I(k),x ));
Same ERROR is coming
And you defined all arrays to be symbolic ?
Yes, code ran successfully.
Thanks but where is the option to Accept your answer?

Sign in to comment.

Answers (0)

Asked:

on 29 Jun 2022

Edited:

on 29 Jun 2022

Community Treasure Hunt

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

Start Hunting!