MATLAB: Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 101-by-101.

cfdindexunable to perform assignment

Hello
I have problem with my code and I can't find the right solution. even if I've change my matrices to a uniform one (like 100*100)
I will be appreciate you if you answer.
best wishes
clc
clear all
close all
ID = 80;
Q = 2/(30*24*60*60);
k = (ID * 10)/(30*24*60*60);
D = 0.02 * ID;
S = 0.018;
xmin = 0; ymin = 0;
xmax = 20000; ymax = 20000;
nSS = 100;
dx = xmax / nSS;
dy = dx;
dt = 1000;
Tmax = 30*24*60*60;
nTS = Tmax / dt;
xw = 10000;
yw1 = 5000;
yw2 = 15000;
xp1 = 5000;
xp2 = 15000;
yp = 10000;
h = 80*ones(20000/dx +1 , 20000/dy +1 );
for t = 1:nTS
for i = 2:nSS
for j = 2:nSS
if i == xw/dx +1 && j == yw1/dy +1
h(i,j) = (1/(S*dx*dy))*(((k*0.5*dt)*(dy*(((h(i+1,j)^2)-(2*(h(i,j)^2))+...
(h(i-1,j)^2))/dx)+dx*(((h(i,j+1)^2)-(2*(h(i,j)^2))+(h(i,j-1)^2))/dy)))-dx*dy*dt*Q)+h(j,i);
elseif i == xw/dx +1 && j == yw2/dy +1
h(i,j) = (1/(S*dx*dy))*(((k*0.5*dt)*(dy*(((h(i+1,j)^2)-(2*(h(i,j)^2))+...
(h(i-1,j)^2))/dx)+dx*(((h(i,j+1)^2)-(2*(h(i,j)^2))+(h(i,j-1)^2))/dy)))-dx*dy*dt*Q)+h(j,i);
elseif i == xw/dx +1 && j>= yw1/dy && j<=yw2/dy
h(i,j) = (1/(S*dx*dy))*(((k*0.5*dt)*(dy*(((h(i-1,j)^2)-(2*(h(i,j)^2))+...
(h(i-1,j)^2))/dx)+dx*(((h(i,j+1)^2)-(2*(h(i,j)^2))+(h(i,j-1)^2))/dy)))-dx*dy*dt*Q)+h(j,i);
else
h(i,j) = (1/(S*dx*dy))*(((k*0.5*dt)*(dy*(((h(i+1,j)^2)-(2*(h(i,j)^2))+...
(h(i-1,j)^2))/dx)+dx*(((h(i,j+1)^2)-(2*(h(i,j)^2))+(h(i,j-1)^2))/dy))))+h(j,i);
end
end
end
end
u = zeros(101);
v = zeros(101);
for t=1:nTS
for i=1:nSS
for j=1:nSS
if i>=1 && i<=101 && j==1
u(i,j)=0;
v(i,j)=0;
elseif i>=1 && i<=101 && j==101
u(i,j)=0;
v(i,j)=0;
elseif i==101 && j>=1 && j<=101
u(i,j)=0;
v(i,j)=0;
elseif i==1 && j>=1 && j<=101
u(i,j)=0;
v(i,j)=0;
elseif i>= yw1/dy && i<=yw2/dy && j == xw/dx +1
v(i,j)=0;
else
v(i,j) = (k*dy*dt)*(((h(i+1,j)+h(i,j))/2)-((h(i,j)+h(i-1,j))/2));
u(i,j) = (k*dx*dt)*(((h(i,j+1)+h(i,j))/2)-((h(i,j)+h(i,j-1))/2));
end
end
end
end
c = zeros(101);
a1 = 1;
b1 = 1;
c1 = 1;
d1 = 1;
Q = zeros(101);
Q(51,24) = 2;
Q(51,76) = 2;
for t=1:nTS
for i=2:100
for j=2:100
if v(i,j)<0
a1 = 1;
b1 = 0;
else
a1 = 0;
b1 = 1;
end
if u(i,j)<0
c1 = 1 ;
d1 = 0 ;
else
c1 = 0;
d1 = 1;
end
c(i,j)=c(i,j)+((D*dt)/dx)*(((c(i+1,j)-c(i,j))/dx)-(c(i,j)-c(i-1,j))/dx)+...
+((D*dt)/dx)*(((c(i,j+1)-c(i,j))/dx)-(c(i,j)-c(i,j-1))/dx)-...
((k*v*dt)/(dx))*0.5*(a1*(c(i+1,j)-c(i,j))-b1*(c(i,j)-c(i-1,j)))-...
((k*u*dt)/(dy))*0.5*(c1*(c(i,j+1)-c(i,j))-d1*(c(i,j)-c(i,j-1)))+Q;
end
end
end

Best Answer

c(i,j)=c(i,j)+((D*dt)/dx)*(((c(i+1,j)-c(i,j))/dx)-(c(i,j)-c(i-1,j))/dx)+...
+((D*dt)/dx)*(((c(i,j+1)-c(i,j))/dx)-(c(i,j)-c(i,j-1))/dx)-...
((k*v*dt)/(dx))*0.5*(a1*(c(i+1,j)-c(i,j))-b1*(c(i,j)-c(i-1,j)))-...
((k*u*dt)/(dy))*0.5*(c1*(c(i,j+1)-c(i,j))-d1*(c(i,j)-c(i,j-1)))+Q;
The output is for a single element of c but the calculation involves the entire 101x101 arrays u and v