Matrix dimensions must agree.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ravikumar Mevada
am 29 Jul. 2019
Kommentiert: Andrei Bobrov
am 29 Jul. 2019
Hi,
I am very new to the Matlab. I made one function which gives me an array of sinusoids. In arguments, I am providing an array of amplitude, frequency and phase. The other arguments are length and sampling frequency. When I call the function from command line I am getting error mentioned in the title. I have also tried with the .* method.
Can some one guide me the solve the problem?
Thanks.
Error:
Matrix dimensions must agree.
Error in generateSin (line 5)
function [z] = generateSin (a,f, ph,L, Fs)
T = 1/Fs;
tmax = L*T;
t = 0:T:tmax-T;
z = a.*sin (2*pi*t.*f + ph)
end
%command line function call sample : z = generateSin ([3,5,7], [5,10,15], [0,pi/2, pi/6], 1000, 300)
1 Kommentar
Torsten
am 29 Jul. 2019
t is a vector of length 1000, a, f and ph are vectors of length 3. What dimension do you expect z to have ?
Akzeptierte Antwort
Andrei Bobrov
am 29 Jul. 2019
Bearbeitet: Andrei Bobrov
am 29 Jul. 2019
function [z] = generateSin (a,f, ph,L, Fs)
z = (a(:).*sin (2*pi*(0:L-1)/Fs).*f(:) + ph(:))';
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!