What's my error trying to plot

1 次查看(过去 30 天)
Fs = 100;
t = (1:100)/Fs;
s1 = sin(2*pi*t*5); s2=sin(2*pi*t*15); s3=sin(2*pi*t*30);
s = s1+s2+s3;
[b,a] = ellip(4,0.1,40,[10 20]*2/Fs);
[H,w] = freqz(b,a,512) and plot(w*Fs/(2*pi),abs(H));
sf = filter(b,a,s);
S = fft(s,512);
SF = fft(sf,512);
w = (0:255)/256*(Fs/2);
plot(w,abs([S(1:256)' SF(1:256)']))
  2 个评论
Adam Danz
Adam Danz 2020-6-30
If you have a question about an error message, you need to include the full copy-pasted error message.
Lauren Fuentes
Lauren Fuentes 2020-7-1
Thanks for the clarification, I'll make sure to do so next time around...

请先登录,再进行评论。

采纳的回答

Gurpreet Singh
Gurpreet Singh 2020-6-30
Hi Lauren,
This error is occurring because of line 6. There should be delimeter instead of "and".
It should be as follows.
Fs = 100;
t = (1:100)/Fs;
s1 = sin(2*pi*t*5); s2=sin(2*pi*t*15); s3=sin(2*pi*t*30);
s = s1+s2+s3;
[b,a] = ellip(4,0.1,40,[10 20]*2/Fs);
[H,w] = freqz(b,a,512) ; plot(w*Fs/(2*pi),abs(H));
sf = filter(b,a,s);
S = fft(s,512);
SF = fft(sf,512);
w = (0:255)/256*(Fs/2);
plot(w,abs([S(1:256)' SF(1:256)']))

更多回答(1 个)

SC
SC 2020-6-30
is the error you are getting:
"Invalid expression. Check for missing multiplication operator,
missing or unbalanced delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses." ?
This maybe because of 'and' in your code at line:6
Try the following:
Fs = 100;
t = (1:100)/Fs;
s1 = sin(2*pi*t*5); s2=sin(2*pi*t*15); s3=sin(2*pi*t*30);
s = s1+s2+s3;
[b,a] = ellip(4,0.1,40,[10 20]*2/Fs);
[H,w] = freqz(b,a,512);
plot(w*Fs/(2*pi),abs(H));
sf = filter(b,a,s);
S = fft(s,512);
SF = fft(sf,512);
w = (0:255)/256*(Fs/2);
plot(w,abs([S(1:256)' SF(1:256)']))

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

产品


版本

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by