How could I solve this error?

1 次查看(过去 30 天)
this code does not have any problem with respect to r and t, but when I add interval for t and r it gives this error
thanks for helping
B=(2/pi)^(1/2);
r1=0.00001;
k=0.42;
Cp=3600;
g=1000;
rho=1048;
Tb=37;
qm=300;
w=0.0005;
ra=0.01;
%%
c=w*rho*Cp;
r_distance=ra*2;
time_total=1;
dr=r_distance/10;
dt=0.1;
rmesh=0:dr:r_distance;
tmesh=0:dt:time_total;
rskip=2;
tskip=2;
number_iterations=2;
nr=length(rmesh);
nt=length(tmesh);
V=zeros(nt,nr);
for i=1:nt
for j=1:nt
for m=1:number_iterations
q = int((((B*(rp*sqrt(c))^(-0.5)*sin(rp*sqrt(c))/(sqrt(rp)*B*(sqrt(c))^(-0.5)*sin(sqrt(c)))))-1)*rp*sin(m*pi*rp),rp,0,1); % the integral r prime from 0 to 1
first_term = symsum((exp((m*pi)^2+c)*(-tmesh(j)))*sin(m*pi*rmesh(i))*q, m, 1, 10); % a summation
end
end
end
Error using sym/symsum (line 52)
Cannot compute the sum with respect to '1'. The summation index must be a symbolic variable.
Error in test (line 36)
first_term = symsum((exp((m*pi)^2+c)*(-tmesh(j)))*sin(m*pi*rmesh(i))*q, m, 1, 10); % a summation
  7 个评论

请先登录,再进行评论。

采纳的回答

darova
darova 2021-8-23
You are using the same variable as in for loop. That why you have an error

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by