symbolic error in calculation

4 views (last 30 days)
yogeshwari patel
yogeshwari patel on 13 Nov 2022
Commented: yogeshwari patel on 23 Nov 2022
syms x
syms a
syms t
syms f % f fractional order
syms r % r cut
% syms m
% m=0.7;
U=zeros(1,2,'sym');
A=zeros(1,2,'sym');
B=zeros(1,2,'sym');
series(x,t)=sym(zeros(1,1));
U(1)=(r-1)/((1+exp(x))^2);
r=0.3
r = 0.3000
for k=1:4
A(1)=0;
for i=1:k
A(1)=A(1)+U(i)*U(k-i+1) ;
end
U(k+1)=simplify(gamma((f*(k-1)+1))/gamma((f*(k)+1))*(diff(U(k),x,2)+6*U(k)-6*A(1)));
end
disp (U)
for k=1:5
series(x,t)=series(x,t)+U(k)*(power(t,k-1));
end
series
series(x, t) = 
C=zeros(1,1);
for x=1:5
e=x;
for t=1:5
f=(t)/10;
C(x,t)=series(e,f);
end
end
Unable to perform assignment because value of type 'sym' is not convertible to 'double'.

Caused by:
Error using symengine
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for variables.
vpa(C,15)
The last for loop is not evaluating the numerical value .Previously when I use the code the values were evaluated but now its showing the error.
  5 Comments

Sign in to comment.

Answers (1)

Bhavana Ravirala
Bhavana Ravirala on 16 Nov 2022
The last for loop is failing because you are trying to assign sym variable (output of ‘series’ is a sym variable) to double variable. To eliminate this error, define C as a sym variable which gives a numeric output.
C=zeros(1,1,sym);
  2 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by