syntax - 为什么使用 ODE 系统在八度音阶中给出语法错误
问题描述
这似乎是我的 ODE 系统特别是 xdot(2) 的解析/语法错误。但我无法弄清楚
我在 StackOverflow 中检查了类似的问题,但我没有找到我的解决方案
function xdot = f3(x, t)
xdot =zeros(2, 1);
x=zeros(1, 2);
r_1=4;
R_1=1;
p_1=8;
l_1=0.2;
r_2=10;
p_2=10;
R_2=2;
l_2=50;
rM= 0.01;
d=2;
xdot(1)= ((r_1*p_1*x(3))/(1+p_1*x(3)))*x(1)-r_1*x(1)^2-(R-1*x(1))/(1+r_1*x(3)-x(1)*x(2)
xdot(2)= rM + ((r_2*p_2*x(3))/(1+p_2*x(3)))*x(2)-r_2*x(2)^2-(R_2*x(2))/(1+p_2*x(3))
xdot(3)= d - (l_1*r_1*x(1))/(1+p_1*x(2))-(l_2*r_2*x(2)/(1+r_2*x(3))
endfunction
x0 = [1; 0; -1];
t = linspace(0, 2, 201);
x = lsode (@f3, x0, t);
figure(1);
plot(t, x(:,1));
xlabel('t');
ylabel('X');
title('X - component');
figure(2);
plot(t, x(:,2));
xlabel('t');
ylabel('Y');
title('Y - component');
应该解决系统颂歌但给我
f3
parse error near line 18 of file C:/Users/Admin/Desktop\f3.m
syntax error
>>> xdot(2)= rM + ((r_2*p_2*x(3))/(1+p_2*x(3)))*x(2)-r_2*x(2)^2-
(R_2*x(2))/(1+p_2*x(3))
^
解决方案
那里似乎有几个问题。
您正在创建大小为 2 的 xdot 和 x 值,但在索引 3 处访问/设置。
为了
xdot(1)= ((r_1*p_1*x(3))/(1+p_1*x(3)))*x(1)-r_1*x(1)^2-(R-1*x(1))/(1+r_1*x(3)-x(1)*x(2)
a)您缺少导致语法错误的“)”。
b)这
R-1
是不正确的 - 你没有'R'所以它可能意味着R_1在
xdot(3)= d - (l_1*r_1*x(1))/(1+p_1*x(2))-(l_2*r_2*x(2)/(1+r_2*x(3))
中,您缺少一个 ')'
推荐阅读
- javascript - Illustrator:从“javascript”打开的 PDF 中获取描边颜色代码
- php - 尝试在按钮单击时将数据插入另一个表
- kubernetes - 使用 istio 作为外部 TLS 服务的反向代理
- android - 在片段 Kotlin 中使用 ContextCompat.getColor?
- javascript - 在 rgba 问题中替换 alpha
- python - 将x位数转换为两位数
- ggplot2 - ggplot2 geom_text 在饼图中的位置
- java - 如何排除某些依赖项被添加到 Maven 中的 Class-Path?
- dask - GPU Dask Cuda 集群:client.submit
- scala - 将 prepareStament 对象转换为 Json Scala