Error while using DAE example
Afficher commentaires plus anciens
I'm trying out the following example, http://in.mathworks.com/help/symbolic/set-up-your-dae-problem.html, of simulating a pendulum, whose characteristics is described by a differential algebraic expression. But I've hit a dead end at step 5, finding consistent initial consitions. For some reason the decic function returns the following error. I'm using matlab 2014b.
Error using
symengine>makeFhandle/@(t,in2,in3,param1,param2,param3)[-(in2(3,:).*in2(1,:)-in2(7,:).*param1.*param2)./param2;(-in2(3,:).*in2(2,:)+in2(6,:).*param1.*param2+param1.*param2.*param3)./param2;-param2.^2+in2(1,:).^2+in2(2,:).^2;in2(4,:).*in2(1,:).*2.0+in2(5,:).*in2(2,:).*2.0;in2(7,:).*in2(1,:).*2.0+in3(5,:).*in2(2,:).*2.0+in2(4,:).^2.*2.0+in2(5,:).^2.*2.0;in2(6,:)-in3(5,:);in2(5,:)-in3(2,:)]
Not enough input arguments.
Error in decic (line 66)
res = feval(odefun,t0,y0,yp0,varargin{:});
Error in Untitled (line 38)
[y0, yp0] = decic(f, 0, y0est, [], yp0est, [], opt)
Here's the entire code I tried.
clear all
clc
%Equations and variables
syms x(t) y(t) T(t) m r g;
eqs= [m*diff(x(t), 2) == T(t)/r*x(t), ...
m*diff(y(t), 2) == T(t)/r*y(t) - m*g, ...
x(t)^2 + y(t)^2 == r^2];
vars = [x(t); y(t); T(t)];
%reducing differential order
[eqs, vars, R] = reduceDifferentialOrder(eqs, vars);
%reduce DAE index
[DAEs,DAEvars] = reduceDAEIndex(eqs,vars);
[DAEs,DAEvars] = reduceRedundancies(DAEs,DAEvars)
%Finding function handles such as F(t,y(t),y'(t))=0 is reqd for ode15i, So
%convert a DAE system of function handle F=F(t,y,yp), where t is scalar , y
% yp vectors.
f = daeFunction(DAEs, DAEvars, m, r, g);
m = 1.0;
r = 1.0;
g = 9.81;
%The function handle f still contains symbolic parameters. Create a purely
%numeric function handle F that you can pass to ode15i.
F = @(t, Y, YP) f(t, Y, YP, m, r, g);
DAEs = subs(DAEs);
%F = daeFunction(DAEs, DAEvars);
%finding consistent initial conditions
y0est = [0.5*r; -0.8*r; 0; 0; 0; 0; 0];
yp0est = zeros(7,1);
opt = odeset('RelTol', 10.0^(-7), 'AbsTol' , 10.0^(-7));
[y0, yp0] = decic(f, 0, y0est, [], yp0est, [], opt)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!