Applying phase selection on chirp

1 Ansicht (letzte 30 Tage)
tony karamp
tony karamp am 1 Apr. 2013
hello,
I am trying to create a swept-frequency cosine, and I want to be able to set the phase as I please. I tried that code, but I get an error. I want to create a vector mat(1:40), where I can manually set its phase.
Fs = 32000; %Sampling Frequency
t = 0: 1/Fs: 10 -1/Fs; %Time
tt = 10; %Time when the chance occurs
f1 = 20; %Starting Frequency
f2 = 250; %Ending Frequency
cosineph = zeros(1,40); %Phase of sines
for iMat= 1:40
k=iMat/2;
mat(iMat) = chirp(t,k*f1,tt,k*f2,'linear',cosineph(iMat));
end
The error that I am getting is " In an assignment A(I) = B, the number of elements in B and I must be the same."
Now, I am guessing it refers to variable t, so I tried implementing that into an embedded for, but didn't get the results I wanted.
Any advice?
Thanks

Akzeptierte Antwort

tony karamp
tony karamp am 1 Apr. 2013
it seems that the way to go is to replace the vector, with a cell. So the code alters like that:
for iMat= 1:40
k=iMat/2;
mat{iMat} = chirp(t,k*f1,tt,k*f2,'linear',cosineph(iMat));
end

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by