something problem with diff

Hello!This is my code.
syms x;
m = 5; h = 2*pi*x; q= besseli(5,h); k1 = h.^2-q; k = [m*q.*(h-3).*5 0 ; 0 q.*h-2 ]
a = det(k) pretty(diff(k(x)),x) Then,I got this message:
Invalid indexing or function definition. When defining a function, ensure that the body of the function is a SYM object. When indexing, the input must be numeric, logical or ':'.
What does it mean?
Thanks!

 Accepted Answer

Star Strider
Star Strider on 4 May 2014
Edited: Star Strider on 4 May 2014
You haven’t declared k as a function of x previously, so the Symbolic Math Toolbox assumes x is a subscript (that actually makes sense considering that k is a matrix).
Do this instead:
syms x;
m = 5;
h = 2*pi*x;
q= besseli(5,h);
k1 = h.^2-q;
k = [m*q.*(h-3).*5 0 ; 0 q.*h-2 ]
a = det(k)
fprintf('\n\ndiff(k,x) = \n\n') % This makes the output easier to read
pretty(diff(k,x)) % <== Changed line
produces:
diff(k,x) =
/ pi besseli(5, 2 pi x) 50 + #1 (2 pi x - 3) 25, 0 \
| |
\ 0, pi besseli(5, 2 pi x) 2 + pi x #1 2 /
where
besseli(5, 2 pi x) 5
#1 == pi besseli(4, 2 pi x) 2 - --------------------
x

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!