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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by