I need help with matrix size confliction in code
Ältere Kommentare anzeigen
function [xx,tt] = syn_sin(fk, Xk, fs, dur, tstart)
xx = 0;
M = length(fk);
Ts = 1/(fs);
s1 = fs*tstart;
s2 = fs*(dur + tstart);
n = s1:s2;
w = 2*pi*fk(1:M);
tt = (n*Ts);
x = real(Xk(1:M).*exp(j*w.*tt));
xx = xx + x;
plot(tt,xx);
So I'm getting this error: (ignore the line # I had comments in between the code)
Error using .*
Matrix dimensions must agree.
Error in syn_sin (line 58)
x = real(Xk(1:M).*exp(j*w.*tt));
Error in Untitled2 (line 8)
syn_sin([0,100,250],[10,14*exp(-j*pi/3),8*j],10000,0.1,0);
I'm basically trying to create a sin graph using the summation of A*E(jwt) but I can't get the vectorization method to work. I can use a for loop and it works but I'm trying to avoid using that. Any thoughts?
edit: fk, Xk, and w has 3 values and n and tt has 1001. The size confliction seems to not matter in a for loop but I can't get it to work when I vectorize it.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Spline Postprocessing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!