I wrote my code in matlab using symbolic coding and computed the value of symbolic variable T1 in terms of other symbolic variables and then substituted value of other variables to get this humongous term
(83718240305934237709*sin((459*sin(317/100))/100 + (1901*sin(389/200))/500 + (81*sin(399/200))/40 - (1532*sin(2229/1000))/5 + (1107*sin(2289/1000))/1000 + (1684*sin(1397/2000))/5 + (1211*sin(2507/1000))/2500 - (1822*sin(3837...
.....What should i do to simplify this term into a single term for each entry in array.
relevant segment of Code:
L=L1+L2+L3+L4
del_l_q1x=diff(L,q1x)
del_l_q1=diff(L,q1)
format short
T1=diff(del_l_q1x,q1)*q1x+diff(del_l_q1x,q2)*q2x+diff(del_l_q1x,q4)*q4x+diff(del_l_q1x,q1x)*q1xx+diff(del_l_q1x,q2x)*q2xx+diff(del_l_q1x,q4x)*q4xx-del_l_q1
[q1a,q1xa,q1xxa,q2a,q2xa,q2xxa,q4a,q4xa,q4xxa]=data();
%the function data returns the value corresponding to each function parameter(q1a,q1xa...etc)
for c=1:1:120
T1(c)=subs(T1,[q1,q1x,q1xx,q2,q2x,q2xx,q4,q4x,q4xx],[q1a(c),q1xa(c),q1xxa(c),q2a(c),q2xa(c),q2xxa(c),q4a(c),q4xa(c),q4xxa(c)])
%substituting the values of variables by actual numerics
%T1 is an array of size 120 storing different values .
end

 채택된 답변

Star Strider
Star Strider 2019년 5월 25일

0 개 추천

First ‘relevant’ is relative. You left out your syms call, and perhaps others, making it difficult to work with.
To simplify ‘T1’, use the simplify function, with a considerable number of permitted iterations:
T1 = simplify(T1, 'Steps',500)
The vpa function is also useful in simplification, if you have assigned numeric values to your variables.

댓글 수: 3

Abhinav Gupta
Abhinav Gupta 2019년 5월 26일
편집: Abhinav Gupta 2019년 5월 26일
Thanks for your early response but Simpify function didn't work out for me .System just hangs on while executing that code segment when I apply simplify function.
Walter Roberson
Walter Roberson 2019년 5월 26일
Then use the vpa() approach.
Abhinav Gupta
Abhinav Gupta 2019년 5월 26일
Thanks Walter!! It worked quite well.

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

추가 답변 (0개)

질문:

2019년 5월 25일

댓글:

2019년 5월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by