Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How can I fix this error?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I wrote this code:
figure(3)
dt = 0.001;
T = 60;
t = [0:dt:T] ;
omega0 = 2 * pi / T;
for k = 1:20
ck = cos (k * omega0 * t); % cosine component
a(k) = 2/T * ( sum (ECG_ac.*ck) * dt);
sk = sin (k * omega0 * t); % sine component
b(k) = 2/T * ( sum (ECG_ac.*sk) * dt);
end
magnitude = sqrt(a.^2 + b.^2);
plot(magnitude)
but i have this error:
Error using .*
Matrix dimensions must agree.
Error in Q2ECG (line 40)
a(k) = 2/T * ( sum (ck.*ECG_ac) * dt);
what's wrong?
Thanks for your help
0 Kommentare
Antworten (2)
Roger Stafford
am 12 Mär. 2017
Judging by your error message, the two arrays, ck and ECG_ac, have different sizes. That's a no-no.
4 Kommentare
Walter Roberson
am 13 Mär. 2017
T = 60;
t = linspace(0,T,length(ECG_ac));
dt = t(2)-t(1);
omega0 = 2 * pi / T;
for k = 1:20
ck = cos (k * omega0 * t); % cosine component
a(k) = 2/T * ( sum (ECG_ac.*ck) * dt);
sk = sin (k * omega0 * t); % sine component
b(k) = 2/T * ( sum (ECG_ac.*sk) * dt);
end
magnitude = sqrt(a.^2 + b.^2);
plot(magnitude)
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!