Mercurial > hg > ltpda
comparison m-toolbox/test/test_ssm_parametersDiff.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 % Test ssm/parameterDiff | |
3 % | |
4 % Test with an harmonic hoscillator | |
5 % | |
6 % L Ferraioli 11-10-2010 | |
7 % | |
8 % $Id: test_ssm_parametersDiff.m,v 1.4 2010/12/02 17:55:01 adrien Exp $ | |
9 % | |
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 close all | |
12 clc | |
13 clear | |
14 %% set parameters | |
15 | |
16 m = 2; % kg | |
17 k = 0.1; % kg s^-2 | |
18 damp = 0.05; % kg s^-1 | |
19 fs = 1; | |
20 freq = logspace(-2.5,log10(fs/2-0.0001),300); | |
21 | |
22 %% get the system ssm and smodel | |
23 | |
24 sys = ssm(plist('built-in', 'HARMONIC_OSC_1D', 'SYMBOLIC PARAMS',{'M', 'K', 'VBETA'})); | |
25 sys.setParameters('names', {'M', 'K', 'VBETA'}, 'values', [m,k,damp] ); | |
26 | |
27 smod = smodel('1 ./ (M.*((2.*i.*pi.*f).^2) + VBETA.*(2.*i.*pi.*f) + K)'); | |
28 % smod = smodel('1 ./ (M.*((i.*f).^2) + VBETA.*(i.*f) + K)'); | |
29 smod.setParams({'M', 'K', 'VBETA'},{m,k,damp}); | |
30 smod.setXvar('f'); | |
31 smod.setXvals(freq); | |
32 smod.setYunits('kg^-1 s^-2'); | |
33 | |
34 | |
35 %% get derivatives | |
36 | |
37 lsys = parameterDiff(sys,plist('names',{'M', 'K', 'VBETA'},'values',1e-8*[m,k,damp])); | |
38 lsys.modifyTimeStep(plist('newtimestep',1/fs)); | |
39 | |
40 dsmod_M = diff(smod,plist('var','M')); | |
41 dsmod_K = diff(smod,plist('var','K')); | |
42 dsmod_VBETA = diff(smod,plist('var','VBETA')); | |
43 | |
44 %% compare frequency response | |
45 pl = plist('inputs',{'COMMAND.force'},... | |
46 'outputs',{'HARMONIC_OSC_1D.position'},... | |
47 'f',freq); | |
48 sys_none = bode(keepParameters(sys),pl); | |
49 smod_none = eval(smod); | |
50 iplot(sys_none,smod_none) | |
51 | |
52 pl = plist('inputs',{'COMMAND.force'},... | |
53 'outputs',{'HARMONIC_OSC_1D_DIFF_M.position'},... | |
54 'f',freq); | |
55 sys_M = bode(lsys,pl); | |
56 smod_M = eval(dsmod_M); | |
57 iplot(sys_M,smod_M) | |
58 | |
59 | |
60 pl = plist('inputs',{'COMMAND.force'},... | |
61 'outputs',{'HARMONIC_OSC_1D_DIFF_K.position'},... | |
62 'f',freq); | |
63 sys_K = bode(lsys,pl); | |
64 smod_K = eval(dsmod_K); | |
65 iplot(sys_K,smod_K) | |
66 | |
67 pl = plist('inputs',{'COMMAND.force'},... | |
68 'outputs',{'HARMONIC_OSC_1D_DIFF_VBETA.position'},... | |
69 'f',freq); | |
70 sys_VBETA = bode(lsys,pl); | |
71 smod_VBETA = eval(dsmod_VBETA); | |
72 iplot(sys_VBETA,smod_VBETA) |