MATLAB - 棘手颂系统布尔 [英] MATLAB - tricky ode system with boolean

查看:146
本文介绍了MATLAB - 棘手颂系统布尔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:感谢upvotes,现在我终于添加的图像。新增全m.file,虽然我不认为它WASS必要的。在code的关键。

EDITED: Thanks for upvotes, now i finally added images. Added full m.file, although i don't think it wass necessary. The key of the code is.

xp(2)=...-((x(2)>=X2)&(xp(3)>=0)...; 
xp(3)=...-((x(3)>=X3)&(xp(2)>=0))...;

全部code:

function xp=uzdevums1(t,x)
%parametr values
r1 = 0.1; r2 = 1; r3 = 0.2;
K1=100;K2 = 100; K3 = 100;
X2=25;X3=10;
speedx2 = 0.02; speedx3=0.02;
%ode system
xp=zeros(3,1);
xp(1)=r1*(1-x(1)/(x(2)+x(3)))*x(1);
xp(2)=r2*(1-x(2)/K2)*x(2)-((x(2)>=X2)&(xp(3)>=0)&xp(1)>0)*x(2)*x(1)*speedx2; 
xp(3)=r3*(1-x(3)/K3)*x(3)-((x(3)>=X3)&(xp(2)>=0))*x(3)*x(1)*speedx3;

从外壳:
    [T,X = ODE45('uzdevums1',[0 60],[10 80 20]);
这个想法是,直到它接近X2 = 25在XP(2)(绿线的衍生物)布尔前pression应该是真实的,但
为XP(3)(红线衍生物)布尔前pression应该是假的,直到XP(2)改变符号。

from shell: [T,X]=ode45('uzdevums1',[0 60],[10 80 20]); The idea is that boolean expression in xp(2) (derivative of green line) should be true until it approaches X2=25, but boolean expression for xp(3) (derivative of red line) should be false until xp(2) changes sign.

红线= X3确实很好..为标志为XP(2)的变化,布尔epxression现在是真实的,红线改变方向,但绿线没有这样做......换句话说,这两个X(2) > = X2(这是罚款),XP(3)> = 0(我不明白)

Red line = x3 does fine.. as the sign for xp(2) changes, boolean epxression is now true and red line changes direction, but green line fails to do so... in other words both x(2)>=X2 (which is fine) and xp(3)>=0 (which i don't understand)

换句话说:红线正在下降,怎么弄XP(3)> = 0

in other words: red line is falling, how comes xp(3)>=0 ?

在第二个画面,我增加XP(1)> 0和布尔前pression终于变成假的......但为什么不在为XP(3)改签名了吗?!

In 2nd picture i added xp(1)>0 and boolean expression finally become false... but why not at as xp(3) changed sign?!

感谢


推荐答案

如果我理解正确的话,你希望获得帮助的主要事情就是声明 XP的解释(三)> = 0 计算为真。

If I understand you correctly, the main thing you want help with is an explanation of why the statement xp(3)>=0 evaluates to true.

研究你的 XP的计算一步一步的。

xp=zeros(3,1);
xp(1)=r1*(1-x(1)/(x(2)+x(3)))*x(1);
xp(2)=r2*(1-x(2)/K2)*x(2)-((x(2)>=X2)&(xp(3)>=0)&xp(1)>0)*x(2)*x(1)*speedx2; 
xp(3)=r3*(1-x(3)/K3)*x(3)-((x(3)>=X3)&(xp(2)>=0))*x(3)*x(1)*speedx3;

您尝试使用 XP(3)当你计算 XP(2)(副值反之亦然)。但 XP(3)仍然是零,当你在XP的计算中使用它(2),所以前pression XP(3 )方式> = 0 将始终为true

You try to use the value of xp(3) when you calculate xp(2) (and vice versa). But xp(3) is still zero when you use it in the calculation of xp(2), so the expression xp(3)>=0 will always evaluate to true.

这篇关于MATLAB - 棘手颂系统布尔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆