# I need to replace a variable with it equivalent matrix in a function

2 views (last 30 days)
Sarah Kandeel on 28 Dec 2017
Answered: Walter Roberson on 28 Dec 2017
I need the function E to be only in term of the variable 'D'. So I need to replace the 'k' with a matrix the contains only 'D'
This is the value of E:
((17164578615225570660380539555542573*k^(1/2)*log(D + 1))/166153499473114484112975882535043072 + (262204404621380299*2^(1/2)*k^(1/2))/9223372036854775808 + (2424202753736887*3^(1/2)*k^(1/2))/576460752303423488 + (5410351780724089*5^(1/2)*k^(1/2))/2882303761517117440 + (7528960095156179*6^(1/2)*k^(1/2))/36893488147419103232 + (2505730989032972149*10^(1/2)*k^(1/2))/1475739525896764129280 + (8842625771650701*14^(1/2)*k^(1/2))/147573952589676412928 + (3844779561451079*15^(1/2)*k^(1/2))/2882303761517117440 + (8666343670811657*30^(1/2)*k^(1/2))/368934881474191032320 + (6527015628853679*70^(1/2)*k^(1/2))/184467440737095516160 + (22586880285468537*481^(1/2)*k^(1/2))/1365059061454506819584 + (7272608261210661*962^(1/2)*k^(1/2))/42658095670453338112 + (262204404621380299*1443^(1/2)*k^(1/2))/341264765363626704896 + (25999031012434971*2405^(1/2)*k^(1/2))/13650590614545068195840 + (17164578615225570660380539555542573*2886^(1/2)*k^(1/2))/12295358961010471824360215307593187328 + (11534338684353237*4810^(1/2)*k^(1/2))/213290478352266690560 + (2505730989032972149*7215^(1/2)*k^(1/2))/54602362458180272783360 + (8842625771650701*10101^(1/2)*k^(1/2))/5460236245818027278336 + (5410351780724089*14430^(1/2)*k^(1/2))/213290478352266690560 + (6527015628853679*50505^(1/2)*k^(1/2))/6825295307272534097920 + (17164578615225570660380539555542573*k^(1/2))/166153499473114484112975882535043072 - (16874112378505048631143767994485025185249706192634551440106553380308219659367599466850516971541902923029737*2^(1/2)*exp(-k/2))/51497252757440425112805277288666860818505571565988146549138088471163366136405808388884891558723190784000000 + (1873106879296623377528201523369593876137260911885774871866432782906658256160455462683123361*1443^(1/2)*exp(-k/2))/211541712150131259081863894753258598134227480340903307078693681812291920945836011290624000000 - (9491567714229462699209099163400904852480349883408824857456268577003257391100291886801201819*2^(1/2)*D*exp(-k/2))/62165404551223330269422781018352605012557018849668464680057997111644937126566671941632000000 + (509659993860129657973062634657967595021820251147601164616438626444162793929*1443^(1/2)*D*exp(-k/2))/255364614831250860135085966904249941740691031970304302541013396280573952000000 - (1873106879296623377528201523369593876137260911885774871866432782906658256160455462683123361*2^(1/2)*k*exp(-k/2))/1429335892906292291093674964549044581988023515816914237018200552785756222607000076288000000 + (1873106879296623377528201523369593876137260911885774871866432782906658256160455462683123361*2^(1/2)*exp(-k/2)*log((828390857088487*D)/2251799813685248 + 3675208770282009/2251799813685248))/5717343571625169164374699858196178327952094063267656948072802211143024890428000305152000000 + (262204404621380299*2^(1/2)*k^(1/2)*log(D + 1))/9223372036854775808 + (2424202753736887*3^(1/2)*k^(1/2)*log(D + 1))/576460752303423488 + (5410351780724089*5^(1/2)*k^(1/2)*log(D + 1))/2882303761517117440 + (7528960095156179*6^(1/2)*k^(1/2)*log(D + 1))/36893488147419103232 + (2505730989032972149*10^(1/2)*k^(1/2)*log(D + 1))/1475739525896764129280 + (8842625771650701*14^(1/2)*k^(1/2)*log(D + 1))/147573952589676412928 + (3844779561451079*15^(1/2)*k^(1/2)*log(D + 1))/2882303761517117440 + (8666343670811657*30^(1/2)*k^(1/2)*log(D + 1))/368934881474191032320 + (6527015628853679*70^(1/2)*k^(1/2)*log(D + 1))/184467440737095516160 + (509659993860129657973062634657967595021820251147601164616438626444162793929*2^(1/2)*log(D + 1)*exp(-k/2))/6901746346790563787434755862277025452451108972170386555162524223799296000000 + (509659993860129657973062634657967595021820251147601164616438626444162793929*2^(1/2)*D*log(D + 1)*exp(-k/2))/6901746346790563787434755862277025452451108972170386555162524223799296000000 - (509659993860129657973062634657967595021820251147601164616438626444162793929*2^(1/2)*D*k*exp(-k/2))/1725436586697640946858688965569256363112777243042596638790631055949824000000 + (509659993860129657973062634657967595021820251147601164616438626444162793929*2^(1/2)*D*exp(-k/2)*log((828390857088487*D)/2251799813685248 + 3675208770282009/2251799813685248))/6901746346790563787434755862277025452451108972170386555162524223799296000000)/k^(1/2)
given the matrix k in terms of D, how do I replace all the k values in 'E' with the matrix itself?
Thank you.

KSSV on 28 Dec 2017
First evaluate k which is in terms of D..and then substitute D and k in the expression for E.
Make a note of element be element operations. https://in.mathworks.com/help/fixedpoint/ref/times.html

Walter Roberson on 28 Dec 2017
newE = subs(E, k, ReplacementExpression);