function JR1 clear all %close all a=input('Parametro a:'); b=input('Parametro b:'); R0=input('Valore iniziale di R:'); J0=input('Valore iniziale di J:'); global a b ttot=30 [tau,sol] = ode45(@JR1,[0 ttot],[R0 J0]); phi1=zeros(size(tau)); phi2=zeros(size(tau)); phi1=sol(:,1); phi2 =sol(:,2); fin=length(sol); for i=1:fin figure(1) subplot(2,1,1) %plot(phi1,phi2,'g','LineWidth',2) plot(phi1(i),phi2(i),'g.') pause(0.01) xlabel('R', 'FontSize', 24) ylabel('J', 'FontSize', 24) grid on hold on axis([-5 5 -5 5]) subplot(2,1,2) %plot(tau,phi1,'b','LineWidth',2) plot(tau(i),phi1(i),'b.') xlabel('Time', 'FontSize', 24) ylabel('R, J', 'FontSize', 24) hold on plot(tau(i),phi2(i),'r.') %plot(tau,phi2,'r','LineWidth',2) %hold off end function d_phi= JR1(tau,phi) global a b % % Inizializzazione delle variabili. % d_phi = zeros(2,1); % % Sistema di equazioni differenziali. % d_phi(1)= a*phi(1)+b*phi(2); d_phi(2)= b*phi(1)+a*phi(2); %d_phi(1)= a*phi(2); %d_phi(2)= -b*phi(1);