Reproducing signal by it's first 40 harmonics
Mostra commenti meno recenti
I have a following periodic signal:
s(t) = {E*e^(t-ti), t <= 0; 0, t > 0}; E = 10, ti = 1; T = 10
I built a plot with 3 periods of the signal like so:
E = 10; ti = 1; T = 10;
fs = 100;
t1 = -2*T:1/fs:-T; t2 = -T:1/fs:0; t3 = 0:1/fs:T;
s1 = E*exp(t2/ti);
t = [t1 t2 t3]; s = [s1 s1 s1];
figure();
plot(t,s);
I need to find first 40 harmonics of this signal, and restore the signal by them.
How can I do that?
Risposta accettata
Più risposte (1)
Nikita
il 31 Ott 2023
2 Commenti
Walter Roberson
il 31 Ott 2023
The code has
s = [s1 s1 s1];
Because s1 is repeated 3 times, the final result has to have a number of columns that is divisible by 3.
s 1x1001 8008 double
But 1001 is not divisible by 3. Therefor the code you are executing must not be the same as the one posted by @Mathieu NOE
Put a breakpoint in the code at the line
t = [t1 t2 t3]; s = [s1 s1 s1];
and run to there, and check size(s1) and then dbstep to execute the line and then check size(s) . If size(s) does not end up exactly 3 times the size of s1 then you have a serious problem with your MATLAB. If s1 ends up length 1001 and s ends up length 3003 (same as t) then use dbstep repeatedly stepping one line at a time, checking size(t) and size(s) each line, looking for the place that s changes size down to 1001 even though there are no further assignments to s .
Nikita
il 31 Ott 2023
Categorie
Scopri di più su S-Parameters and Linear Components in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

