Contents     Functions         Previous Next     PDF Index

fe_curve

Purpose

Generic handling of curves and signal processing utilities

Syntax

  out=fe_curve('command',MODEL,'Name',...);

nlvs

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, useful 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 model.Stack 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 columns 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 until 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.

% computes 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);
noise_f=fe_curve('fft',noise_h);
figure(1);
subplot(211);fe_curve('plot -gca',noise_h);axis tight;
subplot(212);fe_curve('plot -gca',noise_f);axis tight;

plot

fe_curve('plot',curve); plots the curve curve.
fe_curve('plot',fig_handle,curve); plots curve in the figure with handle fig_handle.
fe_curve('plot',model,'curve_name'); plots the curve of model.Stack named curve_name.
fe_curve('plot',fig_handle,model,curve_name); plots curve named curve_name stacked in .Stack field of model model.

% computes 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',signal,freq,damp);
computes the response spectrum associated to the time signal given in signal. Time derivatives can be obtained with option -v or -a. Time integration with option +v or +a. Pseudo derivatives with option PseudoA or PseudoV. freq and damp are frequencies (in Hz) and damping ratios vectors of interest for the response spectra. For example

wd=fileparts(which('d_ubeam'));
% read the acceleration time signal
bagnol_ns=fe_curve(['read' fullfile(wd,'bagnol_ns.cyt')]);

% read reference spectrum
bagnol_ns_rspec_pa= fe_curve(['read' fullfile(wd,'bagnol_ns_rspec_pa.cyt')]);
% compute response spectrum with reference spectrum frequencies
% vector and 5% damping
RespSpec=fe_curve('ResSpectrum PseudoA',...
                  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');

returny

If curve has a .Interp field, this interpolation is taken in account. If .Interp field is not present or empty, it uses a degree 2 interpolation by default.

To force a specific interpolation (over passing .interp field, one may insert the -linear, -log or -stair option 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 example 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})-1]/length(noise.X{1}))*fs*2*pi; % Freq vector 

% Eliminating frequencies corresponding to the aliased part
% of the noise spectrum
freq=freq(1:length(noise.X{1})/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 sets a curve in the model. 3 types of input are allowed:

When you want to associate a curve to a load for time integration it is preferable to define formally the time dependence (if not curve can be interpolated or extrapolated).

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 a string to evaluate (generally test fcn):
model=fe_curve(model,'set','step 1','TestStep 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 1'),...
                      '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,'TestStep 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);.

You can use following format to define period, amplitude and optionally a stop time: out=fe_curve('Test sin Period Amplitude -stoptime Tf',TimeVector).

Note that you can use a command string following the format out=fe_curve('Test sin Period N Amplitude TotalTime -stoptime Tf') without defining explicitly a time vector. 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 output argument the curve is simply plotted.

test[Ramp,Ricker]

out=fe_curve('TestRamp t0 t1 FinalValue',TimeVector) generates a ramp from time t0 where signal value is 0 to time t1 where signal value is FinalValue.

For OpenFEM compatibility, former call out=fe_curve('TestRamp NStep FinalValue',TimeVector) is still available but should not be used.

out=fe_curve('TestRicker Duration Amplitude',TimeVector) generates Ricker functions representing impacts.

TimeVector is optional.

For example:

C1=fe_curve('test ramp 0.6 0.9 2.3',linspace(0,1.2,300));
C2=fe_curve('TestRicker .6 2',linspace(0,1.2,120));
ci=iiplot; iiplot(C1); iiplot(C2); iicom(ci,';IIx:rickerOnly;IIx:ramp')

testSweep

out=fe_curve('TestSweep f0 f1 t0 t1') generates a sweep cosine from t0 to t1, with linear frequency sweeping from f0 to f1.

Y=cos(2*pi*(f0+f1−f0/NStep*t)*t)

Note that f1 is not the final instant frequency of the signal (which will be f0+2*f1−f0/NStep for ascending sweep).

testStep

out=fe_curve('TestStep t1') generates a step which value is one from time 0 to time t1.

testEval

out=fe_curve('TestEval str') generates the signal obtained by evaluating the string str function of t.

For example, one can generate a sine of 150 Hz and amplitude 2 with

C1=fe_curve('testEval 2*sin(2*pi*150*t)',linspace(0,1.2,3000));
ci=iiplot; iiplot(C1);

timefreq

out=fe_curve('TimeFreq',Input,xf);
computes response of a system with given transfer functions FRF to time input Input. Sampling frequency and length of time signal Input must be coherent with frequency step and length of given transfer FRF.

fs=1024; sample_length=2;                   % 2 sec. long white noise
noise=fe_curve('noise',fs*sample_length,fs);% 1024 Hz of sampling freq.
[t,f,N]=fe_curve('getXTime',noise);

% FRF with resonant freq. 50 100 200 Hz, unit amplitude, 2% damping 
xf=nor2xf(2*pi*[50 100 200].',.02,[1 ; 1 ; 1],[1 1 1],2*pi*f);

Resp=fe_curve('TimeFreq',noise,xf); % Response to noisy input
fe_curve('Plot',Resp); title('Time response');

Window ...

Use fe_curve window to list implemented windows. The general calling format is win=fe_curve('Window Nb_pts Type Arg'); which computes a Nb_pts points window. The default is a symmetric window (last point at zero), the command option -per clips the last point of a N+1 long symmetric window.

For the exponential window the arguments are three doubles. 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-2009 by SDTools
Previous Up Next