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.

 채택된 답변

KSSV
KSSV 2021년 5월 3일

0 개 추천

Use:
plot(f,20*log10(FFT_abs/max(FFT_abs)),'color','b','linewidth',3);

추가 답변 (3개)

Stephen23
Stephen23 2021년 5월 3일
편집: Stephen23 2021년 5월 3일

0 개 추천

Exactly as the plot documentation shows, the LineSpec must come directly after the X/Y data:
plot(f,20*log10(FFT_abs/max(FFT_abs)),'b+-','linewidth',3);
Walter Roberson
Walter Roberson 2021년 5월 3일

0 개 추천

plot(f,20*log10(FFT_abs/max(FFT_abs)),'b+-','linewidth',3);
Named options must always go after all positional parameters.
Mathieu NOE
Mathieu NOE 2021년 5월 3일

0 개 추천

hello
it works better this way :
plot(f,20*log10(FFT_abs/max(FFT_abs)),'b+-','linewidth',3);

댓글 수: 5

Sadiq Akbar
Sadiq Akbar 2021년 5월 3일
Thank you to all of you. But tell me which answer should I accept now as all have given me the correct asnwer?
Mathieu NOE
Mathieu NOE 2021년 5월 3일
me, me, !! (I am not yet MVP !!!)
just kidding, pick the one you want . I am not in a beauty conquest
Mathieu NOE
Mathieu NOE 2021년 5월 3일
what a success . 3 MVP answers for a plot command issue. Wow.
Sadiq Akbar
Sadiq Akbar 2021년 5월 3일
My hear wants to accept all the answers but I think its not possible. Then logically speaking, first of all KSSV has given me the answer, so definitely he has more right though I used the command of Walter Roberson. However thanks to all of you for your prompt responses.
Walter Roberson
Walter Roberson 2021년 5월 4일
KSSV's solution does not set the line style or the marker.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2021년 5월 3일

댓글:

2021년 5월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by