Differentiate big symbolic function

조회 수: 1 (최근 30일)
Pavel
Pavel 2014년 4월 3일
댓글: Walter Roberson 2014년 4월 4일
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

채택된 답변

Walter Roberson
Walter Roberson 2014년 4월 3일
You want to differentiate V1 but you ask to differentiate V instead, and V is not defined.
  댓글 수: 4
Pavel
Pavel 2014년 4월 4일
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
Walter Roberson
Walter Roberson 2014년 4월 4일
solve( diff(V1, a), diff(V1, b), diff(V1, c), a, b, c)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by