What's my error trying to plot

2 views (last 30 days)
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 Comments
Adam Danz
Adam Danz on 30 Jun 2020
If you have a question about an error message, you need to include the full copy-pasted error message.
Lauren Fuentes
Lauren Fuentes on 1 Jul 2020
Thanks for the clarification, I'll make sure to do so next time around...

Sign in to comment.

Accepted Answer

Gurpreet Singh
Gurpreet Singh on 30 Jun 2020
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)']))

More Answers (1)

SC
SC on 30 Jun 2020
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)']))

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Tags

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!