Azzera filtri
Azzera filtri

What's my error trying to plot

1 visualizzazione (ultimi 30 giorni)
Lauren Fuentes
Lauren Fuentes il 30 Giu 2020
Commentato: Lauren Fuentes il 1 Lug 2020
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 Commenti
Adam Danz
Adam Danz il 30 Giu 2020
If you have a question about an error message, you need to include the full copy-pasted error message.
Lauren Fuentes
Lauren Fuentes il 1 Lug 2020
Thanks for the clarification, I'll make sure to do so next time around...

Accedi per commentare.

Risposta accettata

Gurpreet Singh
Gurpreet Singh il 30 Giu 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)']))

Più risposte (1)

SC
SC il 30 Giu 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)']))

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Tag

Prodotti


Release

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by