matlab - generate sinusoidal model with time varying frequency -
I would like to create sinusoidal time series over time, such as changing such occurrences. We have an overview time of 2.93 seconds, for 0 to 1 second, I want to create sinusoidal data in the additive of white noise with a set of weirs, while in the second set of second frequencies of 1 to 2.93 seconds, its I wrote the following code for
% frequency FS = 100 non-constant signal with different time; Sample frequency ts = 1 / fs; T = (0: ts: 2.93); % Time vector% I want to make a signal that is included in the sinusoid components in the infected% of the white noise, in the form of frequencies in X = 25 * sin (2 * pi * 23 * t (t 1)) + 26 * because (2 * pi * 17 * t (t> 1)) + 21 * sin (2 * pi * 29 * t (t> 1)) + 10 * randn (size (t)); Z = [X '; P ']; Plot (t ', z); but it shows me error + +
should agree to the error in using matrix dimensions. Error + 20 * cos (2 * pi * 24 * t (t Where do I have a wrong dimension? Even after the fixing of this problem, does the situation seem to match the situation which I want? Thanks in advance
UPDATED:
% changing non-constant signal frequency with time fs = 100; Sample frequency ts = 1 / fs; T = (0: ts: 2.93); % Time vector t1 = t (t <1); T2 = t (t> = 1); Wn = 10 * randn (size (T1)); WN1 = 10 * randn (size (T2)); Want to make a signal by adding the white noise option to% i, the frequencies are defined as X = 25 * sin (2 * pi * 23 * t (t <1) in time + 20 * cos (2 * exemplary * 24 * t (T & LT; 1)) + 24 * sin (2 * pi * 22 * t (T & LT; 1)) + wn; Y = 21 * sin (2 * pi * 20 * t (t> = 1)) + 26 * because (2 * pi * 17 * t (t> = 1)) + 21 * sin (2 * Pi * 29 * t (t> = 1)) + wn1; Z = [X '; P ']; Plot (t ', z);
Your problem is when randn () finally You are trying to add arrays of different dimensions of your x, y definition size (t) result t (t <1) or t (T> 1) to second value in . Either you can use
x = 25 * sin (2 * pi * 23 * t (t <1)) + 20 * cos ( 2 * pi * 24 * t (t <1)) + 24 * sin (2 * pi * 22 * t (t; l;; 1)) + 10 * randn (size (t (t & lt; 1))); Y = 21 * sin (2 * pi * 20 * t (t> = 1)) + 26 * because (2 * pi * 17 * t (t> = 1)) + 21 * sin (2 * Pi * 29 * t (t> = 1)) + 10 * randn (size (t (t> = 1))); Or you can ignore it and after defining you z : x = 25 * sin ( 2 * pi * 23 * T (T & LT; 1)) + 20 * because (2 * pi * 24 * t (T & lt; 1)) + 24 * sin (2 * pi * 22 * t ( T & LT; 1)); Y = 21 * sin (2 * pi * 20 * t (t> = 1)) + 26 * because (2 * pi * 17 * t (t> = 1)) + 21 * sin (2 * Pi * 29 * t (t> = 1)); Z = [x, y]; Z = z + 10 * randn (size (t)); Both of them should work
Another small mistake is that you "delete" your t == 1 or you T should be used (t & lt; = 1) x or t (t> = 1) in the Y definition or the dimensions of z and t will not be the same
Comments
Post a Comment