MATLAB Answers

error Unbalanced or unexpected parenthesis or bracket

조회 수: 1(최근 30일)
Muhammad Fauzan
Muhammad Fauzan 2021년 7월 28일
댓글: Chunru 2021년 7월 28일
Dy = 10; Dz = 10;
lambda = 0.0001;
a = 90;
v = 3;
Q1 = 1000;
%
xs1 = 2000; ys1 = -1000;xs5 = 2000; ys5 = -2000;xs9 = 6000; ys9 = -2000;
xs2 = 4000; ys2 = 2000;xs6 = 3000; ys6 = 1000;xs10 = 7000; ys10 = 1900;
xs3 = 100; ys3 = 1500;xs7 = 1000; ys7 = -1000;xs11 = 3000; ys11 = 2500;
xs4 = 1000; ys4 = -100;xs8 = 500; ys8 = 2500;xs12 = 8000; ys12 = -1000;
xmin = 0; xmax = 1000;
ymin = -4000; ymax = 4000;
H1 = 100;
%
z = 1.5;
gplot = 1;
gcont = 2;
[x,y] = meshgrid(linspace(xmin,xmax,100),linspace(ymin,ymax,100));
e = ones(size(x));
aa = (90-a)*pi/180;
xx1 = (x - xs1)*cos(aa) - (ys1 - y)*sin(aa); yy1 = (y - ys1)*cos(aa) + (xs1 - x)*sin(aa);
xx2 = (x - xs2)*cos(aa) - (ys2 - y)*sin(aa); yy2 = (y - ys2)*cos(aa) + (xs2 - x)*sin(aa);
xx3 = (x - xs3)*cos(aa) - (ys3 - y)*sin(aa); yy3 = (y - ys3)*cos(aa) + (xs3 - x)*sin(aa);
xx4 = (x - xs4)*cos(aa) - (ys4 - y)*sin(aa); yy4 = (y - ys4)*cos(aa) + (xs4 - x)*sin(aa);
xx5 = (x - xs5)*cos(aa) - (ys5 - y)*sin(aa); yy5 = (y - ys5)*cos(aa) + (xs5 - x)*sin(aa);
xx6 = (x - xs6)*cos(aa) - (ys6 - y)*sin(aa); yy6 = (y - ys6)*cos(aa) + (xs6 - x)*sin(aa);
xx7 = (x - xs7)*cos(aa) - (ys7 - y)*sin(aa); yy7 = (y - ys7)*cos(aa) + (xs7 - x)*sin(aa);
xx8 = (x - xs8)*cos(aa) - (ys8 - y)*sin(aa); yy8 = (y - ys8)*cos(aa) + (xs8 - x)*sin(aa);
xx9 = (x - xs9)*cos(aa) - (ys9 - y)*sin(aa); yy9 = (y - ys9)*cos(aa) + (xs9 - x)*sin(aa);
xx10 = (x - xs10)*cos(aa) - (ys10 - y)*sin(aa); yy10 = (y - ys10)*cos(aa) + (xs10 - x)*sin(aa);
xx11 = (x - xs11)*cos(aa) - (ys11 - y)*sin(aa); yy11 = (y - ys11)*cos(aa) + (xs11 - x)*sin(aa);
xx12 = (x - xs12)*cos(aa) - (ys12 - y)*sin(aa); yy12 = (y - ys12)*cos(aa) + (xs12 - x)*sin(aa);
c1 = 1000*Q1*e./(4*pi*(xx1>0).*xx1*sqrt(Dy*Dz)*v).*exp(-v*yy1.*yy1./(4*Dy*(xx1>0.*(exp(-v*(z-H1)*e./(4*Dz*(xx1>0).*xx1)).*(exp(-v*(z-H1)*e;
Error Unbalanced or unexpected parenthesis or bracket in
c1 = 1000*Q1*e./(4*pi*(xx1>0).*xx1*sqrt(Dy*Dz)*v).*exp(-v*yy1.*yy1./(4*Dy*(xx1>0.*(exp(-v*(z-H1)*e./(4*Dz*(xx1>0).*xx1)).*(exp(-v*(z-H1)*e;
Please Help!!

답변(2개)

Walter Roberson
Walter Roberson 2021년 7월 28일
c1 = 1000*Q1*e./(4*pi*(xx1>0).*xx1*sqrt(Dy*Dz)*v).*exp(-v*yy1.*yy1./(4*Dy*(xx1>0.*(exp(-v*(z-H1)*e./(4*Dz*(xx1>0).*xx1)).*(exp(-v*(z-H1)*e;
1 2 1 2 1 0 1 2 3 4 5 6 5 6 7 6 54 5 6 7 6
You have 6 ( that are not matched with a )

Chunru
Chunru 2021년 7월 28일
You may want to change the c1 line as follows. It is grammatically correct, but not necessarily correct for your problem. You need to check agaist the equation.
You can break down the statement into smaller pieces (easier for checking). MATLAB editor also does the pairing of parentheses when you move the cursor to a parenthesis.
c1 = 1000*Q1*e./(4*pi*(xx1>0).*xx1*sqrt(Dy*Dz)*v) ...
.*exp(-v*yy1.*yy1./(4*Dy*(xx1>0.*(exp(-v*(z-H1)*e./(4*Dz*(xx1>0).*xx1)).*(exp(-v*(z-H1)*e))))));
  댓글 수: 3
Chunru
Chunru 2021년 7월 28일
c1(isinf(c1))=0; c1(isnan(c1)) = 0;

댓글을 달려면 로그인하십시오.

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by