Hello everyone,
I am having an hard time trying to build a Bouc-Wen model on MATLAB. Although it is easy to build on Simulink, I need to learn how to write it on a .m file in order to use Genetic Algorithms on it in the future.
The Bouc-Wen model is defined by the two equations below, one giving the force F in function of displacement and velocity x and dx, constant parameters c0, k, alpha, f0 and a variable z which is defined by a differential equation including velocity dx and constant parameters gamma, nu, n and A.
with :
In a first time, I am trying to compute the force F predicted by the model, for given sinusoidal displacement and velocity, and given constant parameters. To do this, I am trying in a first time to solve the differential equation then trying to use the solution to compute Fmodel
Here is my code using dsolve to solve the differential equation and computing Fmodel:
Ampl = 0.013;
freqHz = 0.6;
t=0:1e-3:20;
X_virt = Ampl*sin(2*pi*freqHz*t);
V_virt = Ampl*2*pi*freqHz*cos(2*pi*freqHz*t);
vp = [650 300 8e4 0 1.2e-6 1e-6 15 2];
dx = V_virt;
syms
z(dx)
z(dx) = dsolve (diff(z) == -vp(5)*abs(dx)*z*(abs(z))^(vp(8)-1)
...
-vp(6)*dx*(abs(z))^(vp(8)) + vp(7)*dx)
Fmodel = vp(1)*V_virt + vp(2)*X_virt + vp(3)*z(dx) + vp(4);
figure(
'Name'
,
'Test BW'
);
grid
on
;
plot (V_virt, Fmodel)
And here is the error message I get :
Error
using symengine (line 59)
Array
sizes must match.
Error
in sym/privBinaryOp (line 903)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error
in
+
(line 7)
X = privBinaryOp(A, B,
'symobj::zip'
,
'_plus'
);
Error
in test_bw (line 20)
Fmodel = vp(1)*V_virt + vp(2)*X_virt + vp(3)*z(dx) + vp(4);
The error may come from the fact that z(dx) is a sym variable so I can't use it like this. As I am a beginner on how to manipulate differential equations, any hints on how to proceed would be awesome.
Many thanks,
Pierre,
PS: I am using R2015a release.