Transform disharmonic signal to harmonic

3 visualizzazioni (ultimi 30 giorni)
Hello Matlab community,
I'd like to convert an aperiodic disharmonic measurement signal into a periodic harmonic signal. The signal given is a distance(x) over displacement(z) signal. Via hanning I've converted it into a periodic signal. Now for the disharmonic part: The idea is to split the signal into n small pieces and to reproduce it via fft(z) into a sine signal, containing data of frequency, amplitude and distance of the event, in order to get a complete sine function for every single of the n pieces I've split the original signal into. This is all for the purpose of solving the differential equation of a mass oscillator with harmonic force (or displacement) input. In the end I'd like to get a converted measurement signal consisting of n different sine functions, where I could store the data of frequency, amplitude and phase in an array, well at least that's the idea... I'd be very thankful for any idea as to how to generate the fft out of this. Will I need a 3-dimensional array or could this be solved with angle(z) for the distance?

Risposta accettata

Star Strider
Star Strider il 28 Gen 2017
I am a bit confused, so I may need you to clarify your question.
It seems to me that if you want to create a ‘long’ version of a ‘short’ sequence, you need to get the amplitudes and frequencies of the real (cosine) terms and complex (sine) terms of your ‘short’ sequence with the Fourier transform. Then create a time vector for as long a time as you want, and give the time vector as the argument to your sum-of-sines-and-cosines function to create the signal you want.
  8 Commenti
Tobias Engelhardt
Tobias Engelhardt il 4 Feb 2017
Just one more little thing: Since I want to do this operation on a stochastic signal which gets split up in little parts, it would be great if the interpolated sine function would end at the same amplitude as the little piece of my signal, so I can put the signal back together with a smooth connection between the parts. How could this be achieved?
Thank you.
Star Strider
Star Strider il 4 Feb 2017
It amazes me what it’s possible to do with the fmincon function (probably because I don’t use it often, so don’t have much experience with it).
I was quite happy with the result it gave here:
x = 0:5;
y = [0 3 7 6 1 0];
f = @(b,x) b(1).*sin(b(2)*2*pi*x); % Objective Function
normrsd = @(b) norm(y - f(b,x)); % Norm-Of-Residuals Function (To Be Optimised)
% % [B, nrmrsd] = fminsearch(normrsd, [7; 0.1]);
c = @(b) [y(end) - sin(b(2)*2*pi*x), -b(1)]; % Inequality Constraints — The Function Has To Be ≥ ‘y(end)’
ceq = @(b) []; % Equality Constraints (None)
b2con = @(b) deal(c(b),ceq(b)); % Create Constraint Function
[B,nrmrsd] = fmincon(normrsd, [7; 0.1], [],[],[],[],[],[],b2con); % Estimate Parameters Given Constraints
fprintf(1, '\n\tAmplitude =\t%5.2f\n\tFrequency =\t%5.2f\n\n', B)
xplot = linspace(min(x), max(x));
fit_f = f(B,xplot);
figure(1)
plot(x, y)
hold on
plot(xplot, f(B,xplot))
hold off
grid
xlabel('\itx\rm \rightarrow')
ylabel('\ity\rm \rightarrow')
legend('Original Signal', 'Sine Function Approximation', 'Location','S')
I documented the code this time with comments.
The nonlinear constraint function construction needs a more detailed description, since it’s not obvious.
The inequality constraint function ‘c(b)’ derives from:
sin(b(2)*2*pi*x) y(end)
that becomes:
y(end) - sin(b(2)*2*pi*x)
and since (here) b(1) simply has to be ≥ 0, it becomes simply:
-b(1)
See the documentation for Nonlinear Constraints for details on the conventions for creating the constraint functions.
My code produces ...
Amplitude = 5.89
Frequency = 0.10
The Plot

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by