可以帮忙看一下为什么数据正常但画不出来图像吗?

9 次查看(过去 30 天)
子宸 白
子宸 白 2022-12-8
评论: Dongyue 2022-12-15
我尝试使用plot画出在不同u之下的ode的解从直线逐渐分叉的图形,但是运行后数据正常,但图像一直是空白,可以帮忙看一下是哪里错了吗?谢谢大家了
这是作图函数:
u=0.8:0.001:1.2;
v=1;x0=1;w0=1;w=0.44;T=2*pi/w;
axis([0.9 1.2 -0.8 1])
hold on
for j=1:length(u)
[t,y]=ode23('zjzdfun',[0:T/100:70*T],[4,4],[],u(j),x0,w0,v,w);
plot(u(j),y(500:100:1400,2),'LineWidth',2);
end
这是主函数
function ydot=zjzdfun(t,y,~,u,x0,w0,v,w)
ydot=[y(2);
u*(x0^2-y(1)^2)*y(2)-w0^2*y(1)-v*cos(w*t)];
end
  1 个评论
Dongyue
Dongyue 2022-12-15
I am not sure whether your code will execute successfully. To me, the code should look like this:
clc; close all; clear;
u=0.8:0.001:1.2;
v=1;x0=1;w0=1;w=0.44;T=2*pi/w;
axis([0.9 1.2 -0.8 1])
j = 1; % use a for loop if you want
fun = @(t,y) zjzdfun(t,y,u(j),x0,w0,v,w);
[t,y] = ode23(fun,[0 70*T],[4,4]);
plot(t,y)
function ydot=zjzdfun(t,y,u,x0,w0,v,w)
ydot=[y(2);
u*(x0^2-y(1)^2)*y(2)-w0^2*y(1)-v*cos(w*t)];
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!