How to create a multisine signal input using idinput given duration and peak value?

29 views (last 30 days)
Hello everyone,
I am setting up a system identification experiment, and I came across the following example for an industrial arm robot with flexible joints:
I am trying to replicate the same input information. However, for my application, the maximum amplitude is 12, and I would like to simulate for 10s. The signals are:
  • Multisine signals with a flat amplitude spectrum in the frequency interval 1-40 Hz with a peak value of 16 rad/s.
  • The multisine signal is superimposed on a filtered square wave with amplitude 20 rad/s and cut-off frequency 1 Hz.
  • Multisine signal with frequencies 0.1, 0.3, and 0.5 Hz, with peak value 40 rad/s.
I started by reading the idinput page, which is helpful, and read more about multsine signals.
clear all
T = 1;
Ts = 1e-3; % Sample time
Tsinput = 0.2; %
Period = T/Ts; % Period = T/Ts*Tsinput
%Generate a Sum-of-Sinusoids Signal.
% Specify that the signal has N samples in each period and P periods.
NumPeriod = 1;
Range = [-12 12];
%Specify the frequency range of the signal between 0 and Nyquist [0 1]
Band = [0 .1];
%Now modify the number, frequency, and phase of the sinusoids
% 2*pi*[1:GridSkip:fix(Period/2)]/Period and the passband pi*Band.
NumSinusoids = 10;
NumTrials = 10;
GridSkip = 2;
SineData = [NumSinusoids,NumTrials,GridSkip];
%Generate the signal using default characteristics for the sine waves.
[u,freq] = idinput([Period 1 NumPeriod],'sine',Band,Range,SineData);
%% Verification
ufft = fft(u);
Fs = 1/Ts;
L = length(u);
w = (0:L-1)*Fs/L;
figure;
subplot(121); stem(w(1:L/2),abs(ufft(1:L/2))) % Plot until Nyquist frequency
subplot(122); stem(w(1:L/2),abs(ufft(1:L/2))) % Just a little zoom
xlim([0 50]);
title('Single-Sided Amplitude Spectrum of u(t)')
xlabel('Frequency (rad/s)')
ylabel('Amplitude')
%Find Peak-Magnitude-to-RMS Ratio of Sinusoid
disp(['Peak-Magnitude-to-RMS Ratio: ' num2str(peak2rms(u))])
%Returns the sum-of-sinusoids signal in u and the frequencies of the sinusoids in freq.
freq = freq/Ts;
%% Final Signal - For hardware
u = iddata([],u,Tsinput,'TimeUnit','seconds');
figure;
plot(u)
Could someone point out a direction to accomplish this task?
Thank you in advance

Answers (0)

Community Treasure Hunt

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

Start Hunting!