How can I make summation using variable symbol

16 ビュー (過去 30 日間)
Osama Aliwat
Osama Aliwat 2022 年 12 月 26 日
コメント済み: Osama Aliwat 2022 年 12 月 26 日
clc
clear
syms p
a=[0.01;0.015];%The cofficeient next to power in the IFC equation
b=[8.5;9.5];%The cofficeientin the IFC equation
B=[4e-4 0; 0 4e-4];
pl =[];
for i=1:length(a)
for j=1:length(a)
pl = pl + p(i)*B(i,j)*p(j)
end
end
Also, can I later on differentiate the pl equation based on p(i)? so i can find dpl/dp1 or dpl/dp2 using such code
for i=1:length(a)
dpl(i)=diff(pl,p(i))
k(i)=1/(1-dpl(i));
end

採用された回答

VBBV
VBBV 2022 年 12 月 26 日
編集済み: VBBV 2022 年 12 月 26 日
clc
clear
ng = 2;
syms p [1 ng]
a=[0.01;0.015];%The cofficeient next to power in the IFC equation
b=[8.5;9.5];%The cofficeientin the IFC equation
B=[4e-4 0; 0 4e-4];
for i=1:length(a)
for j=1:length(a)
pl(j,i) = p(i)*B(i,j)*p(j);
end
Pl(i) = sum(pl(:,i));
end
Pl = sum(Pl)
Pl = 
dp1=diff(Pl,p1); % differentiate with p1
dp2=diff(Pl,p2); % differentiate with p2
Dp = [dp1 dp2];
k=1./(1-Dp)
k = 
  1 件のコメント
Osama Aliwat
Osama Aliwat 2022 年 12 月 26 日
Thank you alot. For the differentiation part it will only find dp1 and dp2 while i need it to find dp3 or dp10 depending on the matrix of a thats why I used for loop

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by