Where is the recursion?
Afficher commentaires plus anciens
I am getting an infinite loop and running out of memory here. Please help find the recursion. I have not used matlab in a while. Thanks!
format
compact
clc
clear all
close all
%%%%%%%%%%%%%%%%%%%%%%
%%% problem 1
% values of k the system would undergo oscillations. (*Hint: Complex
% eigenvalues lead to oscillatory solutions.) 3. Simulate the system in
% MATLAB using ode45, and plot the phase portrait rdot vs.r.
r0 = 1 % m,
rdot0 = 0 % m/s,
m = 1 % kg,
wt = 1 % rad/s, and
k = 2 % N/m.
dt=.01
t=0:dt:10
% % rdot= ( 0 1 )
% % ydot= ( (k-m*w^2)/m 0)
[t,y] = ode45(@rot,[0 10],[2; 0]);
% Plot the solutions for and against t.
plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of van der Pol Equation (\mu = 1) with ODE45');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')
function dydt = rot(t,y)
%VDP1 Evaluate the van der Pol ODEs for mu = 1
% See also ODE113, ODE23, ODE45.
dydt = [y(1); (1-y(1)^2)*y(2)-y(1)];
[t,y] = ode45(@rot,[0 10],[2; 0]);
end
Réponse acceptée
Plus de réponses (1)
ddd ppp
le 3 Mar 2019
0 votes
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!