About partial derivative using Matlab

15 ビュー (過去 30 日間)
autshy
autshy 2013 年 7 月 31 日
I want to get the partial derivative of a complex function, so I used Matlab and writed the following codes:
syms x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20
y(1)=exp(-(u(1)-x1).^2/(2*x2^2));
y(2)=exp(-(u(1)-x3).^2/(2*x4^2));
y(3)=exp(-(u(1)-x5).^2/(2*x6^2));
y(4)=exp(-(u(1)-x7).^2/(2*x8^2));
y(5)=exp(-(u(1)-x9).^2/(2*x10^2));
y(6)=exp(-(u(2)-x11).^2/(2*x12^2));
y(7)=exp(-(u(2)-x13).^2/(2*x14^2));
y(8)=exp(-(u(2)-x15).^2/(2*x16^2));
y(9)=exp(-(u(2)-x17).^2/(2*x18^2));
y(10)=exp(-(u(2)-x19).^2/(2*x20^2));
z(1)=y(1)*y(6);z(2)=y(1)*y(7);z(3)=y(1)*y(8);z(4)=y(1)*y(9);z(5)=y(1)*y(10);
z(6)=y(2)*y(6);z(7)=y(2)*y(7);z(8)=y(2)*y(8);z(9)=y(2)*y(9);z(10)=y(2)*y(10);
z(11)=y(3)*y(6);z(12)=y(3)*y(7);z(13)=y(3)*y(8);z(14)=y(3)*y(9);z(15)=y(3)*y(10);
z(16)=y(4)*y(6);z(17)=y(4)*y(7);z(18)=y(4)*y(8);z(19)=y(4)*y(9);z(20)=y(4)*y(10);
z(21)=y(5)*y(6);z(22)=y(5)*y(7);z(23)=y(5)*y(8);z(24)=y(5)*y(9);z(25)=y(5)*y(10);
m=(2*z(16)+2*z(21)+2*z(22)+z(11)+z(17)+z(23)+z(24)-z(3)-z(9)-2*z(4)-2*z(5)-2*z(10))/(z(1)+z(2)+z(3)+z(4)+z(5)+z(6)+z(7)+z(8)+z(9)+z(10)+z(11)+z(12)+z(13)+z(14)+z(15)+z(16)+z(17)+z(18)+z(19)+z(20)+z(21)+z(22)+z(23)+z(24)+z(25));
mx1=diff('m','x1')
but there are the errors:
??? Error using ==> mupadmex
Error in MuPAD command: Index exceeds matrix dimensions.
Error in ==> sym.sym>sym.subsref at 1381
B = mupadmex('symobj::subsref',A.s,inds{:});
How can I solve the problem? Thanks
  1 件のコメント
Walter Roberson
Walter Roberson 2013 年 7 月 31 日
Have you tried
diff(m, x1)
?

サインインしてコメントする。

採用された回答

autshy
autshy 2013 年 8 月 5 日
this problem was solved now..

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by