i=0;
for N=20:50
T=0.1; NT=N*T; n=0:N; t=0:0.005:NT; nT=n*T; Fs=1/T;
x1=cos(2*pi*nT);
xt1=cos(2*pi*t);
xhat=x1*sinc(Fs*(ones(length(n),1)*t-nT'*ones(1,length(t))));
err=max(abs(xhat(ceil(end/3:end/3*2))-xt1(ceil(end/3):ceil(end/3*2))));
i=i+1;
[errorarray(i)]=err;
end
Hello, I am new to matlab.
I wanna store the output of the error by incrasing sample N.
So, I wanna plot by (N,err)
For this, I need to make array of the output. However, MATLAB says, I have dimention error in my script.
I will be so happy to get some advise.
Have a good day!

 採用された回答

the cyclist
the cyclist 2020 年 3 月 5 日

1 投票

When you index into xt1, you are using
ceil(end/3):ceil(end/3*2)
and when you index into xhat, you are using
ceil(end/3:end/3*2)
In the first iteration of your loop, the first expression evaluates to
134:268
and the second ones evaluates to
134:267
so you have a dimension mismatch when you try to subtract the two vectors.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2020 年 3 月 5 日

回答済み:

2020 年 3 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by