Unexpected MATLAB operator.( error)

clear all
K=10;
well=-1000;
iw=16;
jw=6;
eps=0.0001;
nx= 50;
ny=10;
H=1000;
w=1.7;
u=ones(nx+1,ny+1)*100;
h=H/ny;
maxit=400;
tol=eps*h*h;
for m =1 : maxit
numi=0;
j= 1;
for i = 2 :nx
utemp= (( 2*u(i,j+1) + u(i+1,j) + u(i-1,j))*0.25);
utemp= (1-w)*u(i,j) + w*utemp;
error= abs(utemp - u(i,j));
u(i,j)=utemp;
if (error < tol)
numi=numi +1;
end
end
for j = 2 : ny
for i = 2 : nx
utemp= (( u(i,j-1) + u(i-1,j) + u(i+1,j) + u(i,j+1))*0.25);
if ((i==iw) & (j==jw))
utemp= (( u(i,j-1) + u(i-1,j) + u(i+1,j) + u(i,j+1) + well/K)*0.25);
end
utemp= (1-w)*u(i,j) + w*utemp;
error= abs(utemp - u(i,j));
u(i,j)=utemp;
if (error < tol)
numi=numi +1;
end
end
end
j= ny + 1;
for i = 2 : nx
utemp= (( 2*u(i,j-1) + u(i+1,j) + u(i-1,j))/4);
utemp= (1-w)*u(i,j) + w*utemp;
error= abs(utemp - u(i,j));
u(i,j)=utemp;
if (error < tol)
numi=numi +1;
end
end
if (numi == (nx-1)*(ny+1)) break; end
end
>darcy2d
>m
27
> numi
539
surf(u)
contour(u)
----------------------------------------------------------------
After execution in matlab:
??? Error: File: darcy1.m Line: 53 Column: 1
Unexpected MATLAB operator.
LINE 53: >darcy2d

Answers (2)

Does your code actually have those carrots in there?
>darcy2d
If so, remove the carrots and your problem will be solved
darcy2d
The part from
>darcy2d
onward is an illustration of how to use the file. From there on should not be saved in the file. Everything before that should be saved into a file named darcy2d.m . Then to use it, at the command line invoke
darcy2d
surf(u)
contour(u)
Those commands should not be saved as part of the .m file.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 6 Apr 2012

Community Treasure Hunt

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

Start Hunting!