MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 请教ode45问题 (https://www.labfans.com/bbs/showthread.php?t=21297)

cyhy97 2019-04-02 16:33

请教ode45问题
 
clc
clear all
t0=0; tfinal=10; tspan=[t0 tfinal] %响应时间
x0=[0.2;0] %初始化电感电流值,电容电压值
[t,x]=ode45(‘rlcsys’,tspan,x0); %rlcsys系统微分方程描述函数
figure(1); subplot(211) ;plot(t,x(:,1)); %绘制电流响应曲线图
title(‘电容电压/v’); xlabel(‘时间/s’) %添加标题和横坐标图标
subplot(212) ;plot(t,x(:,2)); %绘制电压响应曲线图
title(‘电感电流/A’); xlabel(‘时间/s’) %添加标题和横坐标图标
figure(2);vc=x(:,1);i=x(:,2);
plot(vc,i);grid %绘制电容电压与电流关系曲线图
title(‘电感电流与电容电压的关系曲线’); %添加标题
xlabel(‘电容电压/v’); ylabel(‘电感电流/A’) %标纵横坐标
function xdot=rlcsys(t,x) %微分方程函数
Vs=1.5;R=1.6;L=2.1;C=0.3; %赋初始值
Xdot=[x(2)/C;1/L*(Vs-x(1)-R*x(2))] %导数关系式子
[t,x]=ode45(‘rlcsys’,tspan,x0); %rlcsys系统微分方程描述函数

错误使用 feval
未定义与 'double' 类型的输入参数相对应的函数 'rlcsys'。

出错 odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

出错 ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);

请问错在哪里,找不出原因,谢谢


所有时间均为北京时间。现在的时间是 06:43

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.