% testode45.m
%-----------------------------------------------------
% 清空所有变量
clear
% 清空屏幕
clc
% 时间跨度取0-0.5,可以空格分隔,也可以用逗号分隔
tspan = [0,1.5];
% 初始值
y0 = [1.732,-5,0.2,pi/2];
% 调用语句
[T,Y] = ode45( @odefun, tspan, y0 );
% 绘图
figure(1);
plot(T,Y(:,1),'-m')
xlabel('时间/s','Fontsize',18);
ylabel('R的变化率(m/s)','Fontsize',18);
title('R的变化率随时间推移的值','Fontsize',18)
legend('R’')
figure(2);
plot(T,Y(:,2),'-r')
xlabel('时间/s','Fontsize',18);
ylabel('θ的变化率(rad/s)','Fontsize',18);
title('θ的变化率随时间推移的值','Fontsize',18)
legend('θ’')
figure(3);
plot(T,Y(:,3),'-b')
xlabel('时间/s','Fontsize',18);
ylabel('R(m)','Fontsize',18);
title('R随时间推移的值','Fontsize',18)
legend('R')
figure(4);
polarplot(Y(:,4),Y(:,3),'-k')
rlim([0 0.5]);
thetalim([0 360]);