The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Christos Mountrichas

Posts: 2
Registered: 12/29/12
Warning: Input arguments must be scalar.
Posted: Dec 29, 2012 7:21 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic 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
for i = 2: nx-1
c(i,j) = s*c(i, j-1) + r*(c(i-1,j-1)+c(i+1,j-1));
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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

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