Why this code gives error?
2 ビュー (過去 30 日間)
古いコメントを表示
clear all
close all
N=1001;
f1=1.0000e9;
f2=1.0200e9;
fs=4*f1;
w1=2*pi*f1/fs;
w2=2*pi*f2/fs;
n=0:N-1;
s1=sqrt(1.00)*exp(i*w1*n);
s2=sqrt(0.10)*exp(i*w2*n);
wn=sqrt(0.10)*(randn(1,N)+i*randn(1,N));
x=s1+s2+wn;
x=x(:);
f=0:fs/(N-1):fs;
FFT_abs=abs(fft(x));
plot(f,20*log10(FFT_abs/max(FFT_abs)),'linewidth',3,'b+-');
It gives this error:
Error using plot
Data must be a single matrix Y or a list of pairs X,Y.
0 件のコメント
採用された回答
その他の回答 (3 件)
Walter Roberson
2021 年 5 月 3 日
plot(f,20*log10(FFT_abs/max(FFT_abs)),'b+-','linewidth',3);
Named options must always go after all positional parameters.
0 件のコメント
Mathieu NOE
2021 年 5 月 3 日
hello
it works better this way :
plot(f,20*log10(FFT_abs/max(FFT_abs)),'b+-','linewidth',3);
5 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!