MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by a
on 3 Feb 2013

Dear all, I have two waves(one is wave load on the modal and other sinusoidal oscillation of one boundary of the modal. I combined the waves in matlab with this code.

t = 0:1:100; x = 1.949*sin(2*pi*0.08416*t+5.97219) + 2*sin(2*pi*0.1111*t); plot(t,x);

I want to find the frequency of the combined waveform.

Data for the wave

- Wave 1) Amplitude = 1.949m , frequency = 0.5288 rad/sec, phase angle = 5.97219
- Wave 2) Amplitude = 2m frequency = 0.69813 rad/sec, phase angle = 0

Thanks

Answer by Wayne King
on 4 Feb 2013

Accepted answer

There is no way to define a single frequency for this waveform. The waveform is the superposition of 2 frequencies, 0.08416 cycles\second (sample) and 0.1111 cycles\second (sample).

Show 1 older comment

Wayne King
on 4 Feb 2013

Thank you for your comment Image Analyst, I agree with you if the two frequencies are rational numbers then you can find the common period. So for example if the two frequencies were 0.083333 and 0.1111. Because 0.083333 is 1/12 and 0.1111 is 1/9, you can find the least common multiple to be the common period.

t = 0:500; x = 1.949*sin(2*pi*1/12*t+5.97219) + 2*sin(2*pi*1/9*t); plot(t,x) T = 0:lcm(12,9):length(t); set(gca,'xtick',T); x(T+1)

The difficult I was having was in seeing 0.08416 as a rational number. What is the repeating sequence.

Image Analyst
on 4 Feb 2013

0.08416 and 0.1111 are rational numbers because they're finite. Their periods are 1/0.08416 = 11.8821292775665 and 1/0.1111 = 9.000900090009, so in a distance of 106.949858483947 you'd have about 11.88 cycles of wave #1 and 9 cycles of wave #2, and the pattern would repeat again, right?

But I agree with you it's not like you can combine two monochromatic waves and get a new monochromatic wave at a different frequency. If you consider it in the Fourier domain, each wave just gives a delta function (a dot) - they don't combine to give another dot in a different location (at a new frequency).

Normally one would *not* say that the period (frequency) of the "pattern repeat" is some new fundamental frequency of a combined waveform. If you play your tuba at the same time as I play my piccolo, we don't suddenly sound like a clarinet.

a
on 5 Feb 2013

Thanks all for your replies.

Actually i am new here and its my first post. I'm sorry as i was supposed to give the background of the problem. I'm working on an offshore problem. My model is a Pipe whose first few natural frequencies are 0.25241 , 0.50455, 0.75615, 1.0069, 1.2566, 1.5008.... rad/sec. The loads on the modal are (harmonic) 1) Random Wave 2) Oscillation of pipe at top(pipe is attached to a ship).

I plotted PSD for section moment (power spectral density)for case 1 = when only randon wave is acting and case 2 = random wave + ship motion

Random waves are generated from a single wave of Amplitude = 6m and T = 9sec into 50 waves. The first wave have frequency 0.52 rad/sec. So for case 1 i am getting a peak in the PSD plot around 0.45 rad/sec which is close to both natural frequency of pipe and also the frequency of the random wave , hence justifying the peak.

The issue is with the case 2 ... When i plot the PSD for this case i am getting peak around 0.16 rad/sec which may be considered close to 0.25 rad/sec (natural frequency of model) but the frequency of random wave starts with 0.52 rad/sec and also the frequency of ship oscillation is 0.69 rad/sec. both frequencies quiet far from the natural frequencies. So i was just wondering may be these 2 frequencies combined to give a new frequency close to 0.16 rad/sec where the peak appeared in the PSD.

I agree with Wayne King that there cannot be single frequency as we can see the pattern of wave when those 2 waves are combined.

Coming to the point of Image Analyst that the wave pattern is repeating at some period. That period is around T=36 . so the frequency will be close to 0.17 rad/sec. If this is true then it justifies the Peak i am getting in the PSD which is at 0.16 rad/sec.

Wayne King as u said there cannot be single frequency for the combined waves, but can this(0.17 rad/sec) be one of its frequencies??

Answer by Miroslav Balda
on 4 Feb 2013

It is not clear what you want to find. However, the next code finds all parameters of the combined wave, i.e. amplitudes, frequencies and phases of a signal composed out of 2 sinewaves:

| % Azzi %%%%%%% 4.2.2013 clc clear all close all global p0 x t N = 100; T = 1; T1 = N*T; t = (0:N-1)*T; x = 1.949*sin(2*pi*0.08416*t+5.97219) + sin(2*pi*0.1111*t); df = 1/T1; f = (0:N-1)*df; pL = {'FontSize',12,'FontWeight','bold'}; % label font properties pT = {'FontSize',14,'FontWeight','bold'}; % title font properties h1 = fig(1); % www.mathworks.com/matlabcentral/fileexchange/9035 plot(t,x); hold on; grid; xlabel('t [s]',pL{:}) ylabel('fun(t)',pL{:}) title('fun(t) = sum of two sines',pT{:}) % Find initial estimates of parameters: X = fft(x)*T; % approximation of FT aX = abs(X); L = extr(aX); % www.mathworks.com/matlabcentral/fileexchange/10272 Xp = aX(L{1}); % peaks fp = f(L{1}); % frequency at peaks h2 = fig(2); plot(f,aX, f(L{1}),Xp,'or'); hold on; grid; xlabel('f [Hz]',pL{:}) ylabel('modulus of fft(fun(t))',pL{:}) title('fft(fun(t))',pT{:}) p0 = zeros(6,1); % Find vector of initial estimates: p0(1:2) = fp(1:2)'; % frequencies at peaks p0(3:4) = 2*Xp(1:2)'/N; % rough amplitude estimates quota = imag(X(L{1}))./real(X(L{1})); p0(5:6) = atan(quota(1:2))';% phases % Solution of an overdetermined set of nonlinear equations % LMFnlsq from www.mathworks.com/matlabcentral/fileexchange/17534 [p,ssq,cnt] = LMFnlsq(@resid,ones(size(p0)),'Display',-1); fprintf('\n p0 p\n\n'); fprintf('%15.10f%15.10f\n', [p0, p.*p0]'); fun = resid(p)' + x; figure(h1); pause(1) plot(t,fun,'--r')

The program applies three functions from FEX - `fig` for figure placement, `extr` for finding extremal values in a vector, and `LMFnlsq` for least squares solution of an overdetermined system of nonlinear equations by Levenberg-Marquardt method in Fletcher's modification.

The code is able to solve more general task then the given one - all frequencies, amplitudes and phases are assumed being unknowns. The solution `p` of the given problem has been found in 9 iterations starting from the initial estmates `p0`, which have been obtained applying FFT to given time series. The initial parameters `p0` and the obtained solution `p` have been

| p0 p

0.0800000000 0.0841600000 0.1100000000 0.1111000000 1.4570270622 1.9489999990 0.7896867594 1.0000000004 -0.5751678654 -0.3109953111 -1.3988961788 0.0000000020|

Since the p parameters practically equal those from the formula for `x`,
the original line and that with evaluated `p` coincide.

Sorry, if you need something else.

## 0 Comments