Filter löschen
Filter löschen

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

9 Ansichten (letzte 30 Tage)
子宸 白
子宸 白 am 8 Dez. 2022
Kommentiert: Dongyue am 15 Dez. 2022
我尝试使用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 Kommentar
Dongyue
Dongyue am 15 Dez. 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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Annotations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!