matrix dimension errors in trig-fourier serier

1 回表示 (過去 30 日間)
Nathan Ross
Nathan Ross 2021 年 4 月 29 日
コメント済み: Nathan Ross 2021 年 4 月 29 日
Hi everyone, I am trying to graph a trigonemetric fourier series,and I am pretty sure I have all the required parts but I keep getting matrix dimension errors on the final multiplication process. I know this is a fairly small issue but can I get some help correcting this? Here is my code:
t1=linspace(0,3,2000);
n1=100;
A0=0.75;
f1=A0*ones(size(t));
for n2=1:n1
cn=(1.5.*sin(2*pi*n2))./(2*pi*n2);
dn=(-1./(pi*n2)).*(0.75*cos(2*pi*n2)-1);
f1=f1+cn.*cos(2*pi*n2*t1)+dn.*sin(2*pi*n*t1)
end
plot(t1,f1);

採用された回答

VBBV
VBBV 2021 年 4 月 29 日
編集済み: VBBV 2021 年 4 月 29 日
%if true
t1=linspace(0,3,2000);
n1=100;
A0=0.75;
f1=A0*ones(size(t1));
for n2=1:n1
cn=(1.5.*sin(2*pi*n2))./(2*pi*n2);
dn=(-1./(pi*n2)).*(0.75*cos(2*pi*n2)-1);
f1(n2,:)=cn.*cos(2*pi*n2.*t1)+dn.*sin(2*pi*n2.*t1);
end
plot(t1,f1);
Try this option
  1 件のコメント
Nathan Ross
Nathan Ross 2021 年 4 月 29 日
Thank you , that is better.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by