Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Warning: Input arguments must be scalar.
Replies: 3   Last Post: Dec 30, 2012 5:11 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Christos Mountrichas Posts: 2 Registered: 12/29/12
Warning: Input arguments must be scalar.
Posted: Dec 29, 2012 7:21 AM
 Plain Text Reply

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

Date Subject Author
12/29/12 Christos Mountrichas
12/29/12 dpb
12/29/12 Sadik
12/30/12 Christos Mountrichas

© The Math Forum at NCTM 1994-2018. All Rights Reserved.