why i'm getting this error?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
why i'm getting Vectors must be the same length? for an and bn. can someone explain the error also? i always make this mistake
samples = 500;
T = 5;
f0 = 1/T;
t = 0:(1/(samples*f0)):T; % 5 cycles
s = exp((10 - t) / 2);
n = 1:3;
N = 5;
s = repmat(s, [1 N]);
t = 0:(1/(samples*f0)):N*T;
figure()
hold on
plot(t, s)
grid on
a0 = (1/T) * sum(s);
an = (2/T) * s * cos(2*pi*f0*n*t);
bn = (2/T) * s * sin(2*pi*f0*n*t);
thanks
Réponses (1)
Prajith Chilummula
le 5 Avr 2018
Hi ocsse,
The line below produces a vector of size 501.
t = 0:(1/(samples*f0)):T;
repmat repeats the 1X501 matrix 5 times along the row making it 1X2505 size vector.So s has 1X2505 dimension.
s = repmat(s, [1 N]);
The line below produces a vector of dimension 1X2501.
t = 0:(1/(samples*f0)):N*T;
So there is mismatch in sizes of s and t.Therefore you get the error mentioned.
0 commentaires
Voir également
Catégories
En savoir plus sur Matched Filter and Ambiguity Function dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!