fe_curve
Purpose
Generic handling of curves and signal processing utilities
Syntax
out=fe_curve('command',MODEL,'Name',...);
Commands
fe_curve is used to handle curves and do some basic signal processing. The format for curves is described in section 7.9. The iiplot interface may be used to plot curves and a basic call would be iiplot(Curve) to plot curve data structure Curve.
Accepted commands are
bandpass Unit f_min f_max
out=fe_curve('BandPass Unit f_min f_max',signals);
realizes a true bandpass filtering (i.e. using fft() and ifft()) of time signals contained in curves signals. f_min and f_max are given in units Unit, whether Hertz(Hz) or Radian(Rd). With no Unit, f_min and f_max are assumed to be in Hertz.
out=fe_curve('TestFrame');% 3 DOF oscillator response to noisy input
fe_curve('Plot',out{2}); % "unfiltered" response
filt_disp=fe_curve('BandPass Hz 70 90',out{2}); % filtering
fe_curve('Plot',filt_disp); title('filtered displacement');
datatype [,cell]
out=fe_curve('DataType',DesiredType);
returns a data structure describing the data type, usefull to fill .xunit and .yunit fields for curves definition. DesiredType could be a string or a number corresponding to the desired type. With no DesiredType, the current list of available types is displayed.
DataTypeCell returns a cell array rather than data structure to follow the specification for curve data structures.
getcurve
curve=fe_curve('getcurve',model,curve_name);
extracts curve curve_name from the .Stack field of model or the possible curves attached to a load case. If the user
does not specify any name, all the curves are returned in a cell array.
h1h2 input_channels
FRF=fe_curve('H1H2 input_channels',frames,window);
computes H1 and H2 FRF estimators along with the coherence from time signals contained in cell array frames using window window. The time vector is given in frames1.X while input_channels tells which colums of in frames1.Y are inputs. If more than one input channel is specified, true MIMO FRF estimation is done, and H
is used instead of H2. When multiple frames are given, a mean estimation of FRF is computed.
Note: To ensure the proper assembly of H1 and H
in MIMO FRF estimation case, a weighing based on maximum time signals amplitude is used. To use your own, use
FRF=fe_curve('H1H2 input_channels',frames,window,weighing);
where weighing is a vector containing weighing factors for each channel. To avoid weighing, use
FRF=fe_curve('H1H2 input_channels',frames,window,0);
noise
noise=fe_curve('Noise',Nw_pt,fs,f_max);
computes a Nw_pt points long time signal corresponding to a ``white noise'', with sample frequency fs and a unitary power spectrum density untill f_max. fs/2 is taken as f_max when not specified. The general shape of noise power spectrum density, extending from 0 to fs/2, can be specified instead of f_max.
% compute a 2 seconds long white noise, 1024 Hz of sampling freq.
% with "rounded" shape PSD
fs=1024; sample_length=2;
Shape=exp(fe_curve('window 1024 hanning'))-1;
noise_h=fe_curve('noise',fs*sample_length,fs,Shape);
figure(1); subplot(211); % plot time and frequency signals
plot(noise_h.X,noise_h.Y);axis([0 2 -3 3]); xlabel('Time');
subplot(212);
freq=fs*[0:length(noise_h.X)-1]/length(noise_h.X);
plot(freq,20*log10(abs(fft(noise_h.Y))));
axis([0 1024 -20 40]); xlabel('Frequency');
plot
fe_curve('plot',curve);
plots the curve curve named curve_name.
fe_curve('plot',fig_handle,curve);
plots curve in the figure with handle fig_handle.
fe_curve('plot',model,curve_name);
fe_curve('plot',fig_handle,model,curve_name);
plots curve named curve_name stacked in .Stack field of model model.
% compute a 2 seconds long white noise, 1024 Hz of sampling freq.
fs=1024; sample_length=2;
noise=fe_curve('noise',fs*sample_length,fs);
noise.xunit=fe_curve('DataType','Time');
noise.yunit=fe_curve('DataType','Excit. force');
noise.name='Input force';
fe_curve('Plot',noise);
resspectrum [True, Pseudo] [Abs., Rel.] [Disp., Vel., Acc.]
out=fe_curve('ResSpectrum [T, P] [A, R] [D, V, A]',signal,freq,damp);
computes [true, pseudo] [absolute, relative] [displacement, velocitiy,
acceleration] response spectrum associated to the time signal given in signal. signal is a curve type structure where .X, .Y, .ylabel.unit fields must be filled. freq and damp are frequencies (in Hz) and damping ratios vectors of interess for the response spectra.
st=sprintf('read %s',which('bagnol_ns.cyt'));
bagnol_ns=fe_curve(st); % read the acceleration time signal
st=sprintf('read %s',which('bagnol_ns_rspec_pa.cyt'));
bagnol_ns_rspec_pa= fe_curve(st); % read reference spectrum
% compute response spectrum with reference spectrum frequencies
% vector and 5% damping
RespSpec=fe_curve('ResSpectrum True Rel. Acc.',...
bagnol_ns,bagnol_ns_rspec_pa.X/2/pi,.05);
fe_curve('plot',RespSpec); hold on;
plot(RespSpec.X,bagnol_ns_rspec_pa.Y,'r');
legend('fe\_curve','cyberquake');
plot(RespSpec.X,bagnol_ns_rspec_pa.Y,'r');
returny
It uses a degree 2 interpolation by default. To use a linear interpolation, you may insert the -lin string in the command.
To extract a curve ,curve_name and return the values Y corresponding to the input X, the syntax is
y = fe_curve('returny',model,curve_name,X);
Given a curve data structure to return the values Y corresponding to the input X, the syntax is
y = fe_curve('returny',curve,X);
testframe
out=fe_curve('TestFrame');
computes the time response of a 3 DOF oscillator to a white noise and fills the cell array out with noise signal in cell 1 and time response in cell 2. It illustrates the use of various functionalities of fe_curve and provides typical exemple of curves.
fs=512; ech_length=4; % sampling frequency and sample length (s)
noise=fe_curve('Noise',fs*ech_length,fs); % computes noise
% build the curve associated to the time signal of noise
out{1}=struct('X',noise.X,'Y',noise.Y,'xunit',...
fe_curve('DataType','Time'),'yunit',...
fe_curve('DataType','Excit. force'),'name','Input at DOF 2');
% set up an oscillator with 3 DOF %
Puls = [30 80 150]'*2*pi; % natural frequencies
Damp = [.02 .015 .01]'; % damping
Amp = [1 2 -1;2 -1 1;-1 1 2]; % pseudo "mode shapes"
Amp=Amp./det(Amp);
C=[1 0 0]; B=[0 1 0]'; % Observation matrix and Command matrix
freq=([0:length(noise.X)-1]/length(noise.X))*fs*2*pi; % Freq vector
% Eliminating frequencies corresponding to the aliased part
% of the noise spectrum
freq=freq(1:length(noise.X)/2)';
FRF=nor2xf(Puls,Damp,Amp*B,C*Amp,freq); % Transfert function
% Compute the time response to input noise
Resp=fe_curve('TimeFreq',noise,struct('w',freq,'xf',FRF));
% build the curve associated to the time signal of response
out{2}=struct('X',Resp.X,'Y',Resp.Y,'xunit',...
fe_curve('DataType','Time'),'yunit',...
fe_curve('DataType','Displacement'),'name','Output at DOF 1');
set
This command set a curve in the model. 3 types of input are allowed :
-
A data structure, model=fe_curve(model,'set',curve_name,data_structure)
- A string to interprete, model=fe_curve(model,'set',curve_name,string)
- A name refering to an existing curve (for load case only), model=fe_curve( model, 'set LoadCurve',load_case,chanel,curve_name)
The following example illustrates the different calls.
model=fe_time('demo bar'); q0=[];
% curve defined by a by-hand data structure :
c1=struct('ID',1,'X',linspace(0,1e-3,100), ...
'Y',linspace(0,1e-3,100),'data',[],...
'xunit',[],'yunit',[],'unit',[],'name','curve 1');
model=fe_curve(model,'set','curve 1',c1);
% curve defined by : string to interprete :
model=fe_curve(model,'set','step 1','step 1e-4*10');
% curve defined by a reference curve :
c2=fe_curve('test -ID 100 ricker 10e-4 100 1 100e-4');
c3=fe_curve('test sin 10e-4 100 1 100e-4');
model=fe_curve(model,'set','ricker 1',c2);
model=fe_curve(model,'set','sin 1',c3);
% define Load with curve definition
LoadCase=struct('DOF',[1.01;2.01],'def',1e6*eye(2),...
'curve',{{fe_curve('test ricker 20e-4 100 1 100e-4'),...
'ricker 1'}});
model = fe_case(model,'DOFLoad','Point load 1',LoadCase);
% modify a curve in the load case
model=fe_curve(model,'set LoadCurve','Point load 1',2,'step 1e-4*10');
testFunc
This command creates curves based on trigonometric and exponential
functions; the syntax is
out=fe_curve(['Test' st],TimeVector);
where st=sin, cos, tan, exp. The TimeVector contains
the sampling time step, for example: TimeVector=linspace(0.,1.,100).
Note that you may use a command string following the format out=fe_curve('Test sin Period N Amplitude TotalTime -stoptime Tf').
N is the length of the time vector and Tf is the optional time to stop the signal (function is 0 after this time).
Without ouput argument the curve is simply plotted.
test[Ramp,Ricker]
out=fe_curve('TestRamp NStep FinalValue') generates a ramp
composed of NStep steps from 0 to FinalValue.
out=fe_curve('TestRicker Duration Nstep Amplitude TotalTime') generates
Ricker functions representing impacts. For example:
C1=fe_curve('test ramp 20 2');
C2=fe_curve('TestRicker .6 120 2 1.2');
figure(1);plot(C1.X,C1.Y,'-',C2.X,C2.Y,'--')
timefreq
out=fe_curve('TimeFreq',Input,xf);
computes reponse of a system with given tranfert functions FRF to time input Input. Sampling frequency and length of time signal Input must be coherent with frequency step and length of given transfert FRF.
fs=1024; sample_length=2; % 2 sec. long white noise
noise=fe_curve('noise',fs*sample_length,fs);% 1024 Hz of sampling freq.
w=2*pi*fs*[0:length(noise.X)-1]/length(noise.X); % frequency range
% FRF with resonnant freq. 50 100 200 Hz, unit amplitude, 2% damping
xf=nor2xf(2*pi*[50 100 200].',.02,[1 ; 1 ; 1],[1 1 1],w);
Resp=fe_curve('TimeFreq',noise,xf); % Response to noisy input
fe_curve('Plot',Resp); title('Time response');
Window Nb_pts [None, Hanning, Hamming, Exponential] Arg
win=fe_curve('Window Nb_pts Type Arg');
computes Nb_pts points window. Arg is used when Exponential window type is asked.
win = fe_curve('Window 1024 Exponential 10 20 10'); returns an
exponential window with 10 zero points, a 20 point flat top, and a
decaying exponential over the 1004 remaining points with a last point
at exp(-10).
win = fe_curve('Window 1024 Hanning'); returns a 1024 point long hanning window.
See also
fe_load, fe_case
©1991-2007 by SDTools