MATLAB: Calculate derivatives of two complex functions that depend on each other

derivatives

I have two complex functions that depend on each other and I want to calculate their derivatives (like I wrote down).
The problem is, of course: "Undefined function or variable 'f4"
I can I do that?
clc; clear all;
syms x1 x2 x3 x4 h1 h2 h3 h4 h5 u1;
f2(x1, x2, x3, x4, h1, h2, h3, h4, h5, u1)=(h2*x4*(x2+x4)^2*sin(x3)+h3*sin(x3)-h2*f2*cos(x3)+u1)/(h1+h2*cos(x3));
f4(x1, x2, x3, x4, h1, h2, h3, h4, h5, u1)=(h2*x2*x4*sin(x3)+h5*sin(x1+x3)-h2*f2*cos(x3)-h4*f2)/h4;
A21=diff(f2,x1);
subs(A21,[x1,x2,x3,x4],[0 0 0 0])

Best Answer

Why don't you do a 'solve' for 'f1' and 'f2' as the unknowns in the two equations to express each in terms of your ten other variables. Then do the 'diff' operation on each expression.