Differentiate big symbolic function

I have this code:
if true
clear all
clc
% a=alpha1; b=alpha2; c=betha
syms a b c N1 N2 N3 N21 N31 n2 n21 n3 l1 l2 l3 P L sa
% Se calculeaza lungimea elementelor
P=2000;
L=1300;
sa=150;
l1=L/cos(a);
l2=L/cos(b);
l3=L/cos(b+c);
% Se calculeaza A
N21=(-P*cos(b+c)/(cos(b)*sin(b+c)-cos(b+c)));
N31=P/(sin(b+c)-cos(b+c)/cos(b));
n31=(-sin(a)*cos(b)-sin(b)*cos(a))/(sin(b+c)*cos(b)-cos(b+c)*sin(b));
n3=n31;
n21=(cos(a)-n3*cos(b+c))/cos(b);
n2=n21;
%efortul din elementul 1
N1=(-((n2*l2*N21+n3*l3*N31)/(l1+n2^2*l2*n3^2*l3)));
%efortul din elementul 3
N3=(P*cos(b)-N1*sin(a)*cos(b)-N1*cos(a))/(cos(b)*(sin(b+c)-cos(b+c)));
%efortul din elementul 2
N2=(N1*cos(a)-cos(b+c)*N3)/(cos(b));
%definirea functiei obiectiv
V1=simple((N1/sa)*l1+(N2/sa)*l2+(N3/sa)*l3);
V=diff(V1(a,b,c),a)
end
I want to diferentiate V1 with respect to a, b and c but i get the following error:
" Error using sym/subsindex (line 1555) Indexing input must be numeric, logical or ':'.
Error in sym>privformat (line 2367) x = subsindex(x)+1;
Error in sym/subsref (line 1575) [inds{k},refs{k}] = privformat(inds{k});
Error in Derivare2 (line 29) diff_f=diff(V1(a,b,c),a) "
What can i do to solve this problem? Thank you

 采纳的回答

You want to differentiate V1 but you ask to differentiate V instead, and V is not defined.

4 个评论

Sorry. I initialy wanted to differentiate V and I got the error message that i posted, but i thought that if i try to simplify V, it will work, but it didn't. So i named V1 to be the simple form of the equation and I named V to be the different form of V1.
When you build V1 you are applying simple() to an expression, not to a function. Then when you go to integrate you are using V1(a,b,c) which is the syntax for function evaluation (if V1 is a function or function handle) and for indexing otherwise. V1 is a symbolic expression not a function or function handle so indexing is being invoked.
I suspect you want just diff(V1,a)
Thanks a lot. Matlab differentiated the function. I ended up with three equations with the variables a,b and c. How do i solve for a,b and c? Thanks again
solve( diff(V1, a), diff(V1, b), diff(V1, c), a, b, c)

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by