Error while finding determinant

5 次查看(过去 30 天)
Meghna V S
Meghna V S 2021-4-28
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);

回答(2 个)

Shubham Khatri
Shubham Khatri 2021-5-3
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 2021-5-3
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by