Discussion:
Error: Unbalanced or unexpected parenthesis or bracket.
(too old to reply)
Wouter Slechten
2015-12-22 21:01:03 UTC
Permalink
Hello guys, I'm prety new to matlab and i'm trying to solve a differation equasion. I'm using the following .m function I wrote :
function u = onzekerheid(m1,m2,m12,mb,u1,u2,u12,ub)
syms s1 s2 s12 sb;
X(s1,s2,s12,sb) = s1*s2-s12*sb;
Y(s1,s2,s12,sb) = s1*s2*(s12+sb)-s12*sb*(s1+s2);
Z(s1,s2,s12,sb) = Y*(s1+s2-s12-sb)/(X)^2;
t(s1,s2,s12,sb) = X*(1-sqrt(1-Z))/Y;
O(s1,s2,s12,sb) = sqrt([diff(t,s1)*u1]^2+[diff(t,s2)*u2]^2+[diff(t,s12)*u12]^2+[diff(t,sb)*ub]^2);
M = O(m1,m2,m12,mb);
u = M;
end

after that I call for the function 'onzekerheid' from the command window inputting my found values. The command i use for this is :

onzekerheid-1(55.945556,23.218889,77.716667,0.248889,0.965598699,0.622019235,1.138058793,0.063498192)
(note: I saved the file as onzekerheid-1 that's why i call it like this when inputting)

I get this error when trying to input it Error: Unbalanced or unexpected parenthesis or bracket. Any ideas how to fix?
TJ!
2015-12-22 22:27:06 UTC
Permalink
Post by Wouter Slechten
function u = onzekerheid(m1,m2,m12,mb,u1,u2,u12,ub)
syms s1 s2 s12 sb;
X(s1,s2,s12,sb) = s1*s2-s12*sb;
Y(s1,s2,s12,sb) = s1*s2*(s12+sb)-s12*sb*(s1+s2);
Z(s1,s2,s12,sb) = Y*(s1+s2-s12-sb)/(X)^2;
t(s1,s2,s12,sb) = X*(1-sqrt(1-Z))/Y;
O(s1,s2,s12,sb) = sqrt([diff(t,s1)*u1]^2+[diff(t,s2)*u2]^2+[diff(t,s12)*u12]^2+[diff(t,sb)*ub]^2);
M = O(m1,m2,m12,mb);
u = M;
end
onzekerheid-1(55.945556,23.218889,77.716667,0.248889,0.965598699,0.622019235,1.138058793,0.063498192)
(note: I saved the file as onzekerheid-1 that's why i call it like this when inputting)
I get this error when trying to input it Error: Unbalanced or unexpected parenthesis or bracket. Any ideas how to fix?
Hello!

The issue lies with the calling of the function. When "onzekerheid-1(55.945556,..." is entered into the command line MATLAB interprets it as onzekerheid minus 1 next to the bracket (55.945556,...). The 1 before the bracket causes the error e.g. 1(5*5) will result in the same error.

To fix this save your function as "onzekerheid" and call it from the terminal by the following:

onzekerheid(55.945556,23.218889,77.716667,0.248889,0.965598699,0.622019235,1.138058793,0.063498192)

Hope this helps!
-TJ

Loading...