可以帮忙看一下为什么数据正常但画不出来图像吗?
9 views (last 30 days)
Show older comments
我尝试使用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 Comment
Dongyue
on 15 Dec 2022
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
Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!