Error while finding determinant

4 views (last 30 days)
Meghna V S
Meghna V S on 28 Apr 2021
Answered: Steven Lord on 3 May 2021
The code I ran
syms s t
N1 = ((1-s)*(1-t))/4;
N2 =((1+s)*(1-t))/4;
N3 =((1+s)*(1+t))/4;
N4 =((1-s)*(1+t))/4;
x1 =1; x2 = 5; x3 =8; x4 = 1;
y1 = 1; y2 = 1; y3 = 6; y4 = 6;
x = N1*x1 + N2*x2 + N3*x3 + N4*x4
X = simplify(x)
y = N1*y1 + N2*y2 + N3*y3 + N4*y4
Y = simplify(y)
J = [diff(x,s) diff(x,t);diff(y,s) diff(y,t)]
determinant = det(J)
I am getting an error like this:
Error using sym/subsindex (line 857)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Error in sym/subsref (line 902)
R_tilde = builtin('subsref',L_tilde,Idx);

Answers (2)

Shubham Khatri
Shubham Khatri on 3 May 2021
Hello,
Generally this error occurs due to improper use or declaration of the symbolic variables.I tried the code on my end. The code runs fine. To my understanding, you dont have symbolic math toolbox installed. Please refer to this community answer to get support on how to install a new toolbox on existing MATLAB installation.
Hope it helps

Steven Lord
Steven Lord on 3 May 2021
Do you by any chance have a variable named det in your workspace? If so you will not be able to call the det function until that variable is renamed or deleted.
det = 42;
syms x
det([x, x.^2; x.^3, 1])
Error using sym/subsindex (line 864)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!