Date: Dec 29, 2012 7:21 AM
Author: Christos Mountrichas
Subject: Warning: Input arguments must be scalar.

Hi everyone,

I created a script to solve the diffusion equation for a specific situation. However, although i get the right results, I am getting the "Warning: Input arguments must be scalar" message.

Please, I would appreciate any help.

Here is the code:
%
clear; clf; % clean file and clear figure
xmax = 10; % input length of domain in x direction
tmax = 4; % input end time
D = 5.435; % input diffusion coefficient
cb1=0.4; cb2=0; % input boundary concentrations
dx = 1; % input gap between two x coordinates (x=0,1,2...10)
dt = 0.5*dx^2/D; % input time increment
nx=fix(xmax/dx)+1; % total number of x(i)
mt=fix(tmax/dt)+1; % total number of t(j)
r=D*dt/dx^2; s=1-2*r;
t = [0: dt: tmax]; % t(j)
x = [0, dx: xmax]; % x(i)
c = zeros(1:nx,1); c(1,1)=cb1; c(nx,1)=cb2; % c(i,j) at t=0
%
% Generate remaining rows of C
for j = 2: mt
c(1,j)=cb1;
for i = 2: nx-1
c(i,j) = s*c(i, j-1) + r*(c(i-1,j-1)+c(i+1,j-1));
end;
c(nx,j)=cb2;
end;
Cx=c';
t1=fix(1/dt)+1; t2=fix(2/dt)+1; t3=fix(4/dt)+1;
plot(x,c(:,t1),'r-', x,c(:,t2),'b--', x,c(:,t3),'g:'); hold on;
xlabel('x(i)'); ylabel('c(i,j)'); hold on