how to calculate cauchy product in summation

3 ビュー (過去 30 日間)
shiv gaur
shiv gaur 2022 年 3 月 4 日
編集済み: Jan 2022 年 3 月 4 日
a(1)=1;
b(1)=1;
c(1)=1;
S=0;
Z=0;
for i=1:20
for p=1:i-1
a(i+1)=(1/(i+1)).*(a(i)-b(i));
b(i+1)=(1/(i+1)).*(a(i)-S-b(i));
c(i+1)=(1/(i+1))*(Z-c(i));
S=S+a(p)*c(i-p);
Z=Z+a(p)*b(i-p);
disp([S Z])
end
end
S ,Z are cauchy product how to calculate
  2 件のコメント
Ankit
Ankit 2022 年 3 月 4 日
what problem you are facing ?.. inside the loop you are trying to access the element which is not defined
a(i+1)=(1/(i+1)).*(a(i)-b(i));
shiv gaur
shiv gaur 2022 年 3 月 4 日
I am not able to calculate the value the value od S and Z inside the loop which is dependent on the equation of a(i) b(i) and c(i) solve the problem this is new problem

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

回答 (1 件)

Jan
Jan 2022 年 3 月 4 日
The shown code cannot run. In the 1st iteration of the "for i" loop, the inner loop is not entered: "for p = 1:i-1". In the 2nd iteration i=2 the innerloop is entered and in the line
a(i+1)=(1/(i+1)).*(a(i)-b(i));
% ^^^ ^^^
The not existing elements a(2) and b(2) are requested.
Seeing only the failing code does not allow to suggest an improvement, because the readers have no chance to guess, what you want to do instead.
  3 件のコメント
shiv gaur
shiv gaur 2022 年 3 月 4 日
resolve the problem
Jan
Jan 2022 年 3 月 4 日
編集済み: Jan 2022 年 3 月 4 日
@shiv gaur: You have been asked repeatedly to use a proper code formatting. Please read an consider this: https://www.mathworks.com/matlabcentral/answers/help/rtc#rtc_summary . Thanks.
"pl see the runing program" - the code still stops with an error and we still cannot guess, what it should calculate.
"Resolve the problem" is not a polite way to ask for help, but a rough command. Refusing to post your code in a formatted way and posting not running code repeatedly let it look, like it is your intention to provoke the community.

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

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by