“输入参数过多"; [英] "Too Many Input Arguments"

查看:188
本文介绍了“输入参数过多";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个漫长的过程,因为此代码很强大,而且我知道很少有人对解决此类问题感到兴趣,但是我尝试解决这一问题已经一年多了,但我仍然没有找到解决方案.确切的错误是:

This may be a long shot since this code is beefy and I know few people are interested in trouble shooting such things but I have been attempting to troubleshoot this for more than a year and I still haven't figured out a solution. Exact error is:

Error using symengine>@()0.0
Too many input arguments.

Error in bdipuniodefun (line 18)
bdip = [s(4); s(5); s(6); (q/m_e)*(Ex(s(1),s(2),s(3)) + s(5)*Bz(s(1),s(2),s(3)) - s(6)*By(s(1),s(2),s(3))); (q/m_e)*(Ey(s(1),s(2),s(3)) +
s(6)*Bx(s(1),s(2),s(3)) - s(4)*Bz(s(1),s(2),s(3))); (q/m_e)*(Ez(s(1),s(2),s(3)) + s(4)*By(s(1),s(2),s(3)) - s(5)*Bx(s(1),s(2),s(3)))];

Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ode15s (line 150)
    odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);

Error in collisions6 (line 219)
        [T,S] = ode15s(@bdipuniodefun, tspan, icv);

所以我们知道错误发生在哪里,但是我仍然无法解决它.这也是一个不一致的错误.当我运行主脚本"collisions.m"时,它并不总是出现,而是仅在某些内容被更改时才发生.一些例子:我从太多的电子/粒子开始,通常是1000+.或者我尝试输入非零电场.电场函数仍在引用中,但它为零(这是奇怪的部分).我这样做的原因是,尽管错误消失了,但ode求解器的计算甚至无法接近我要寻找的正确解决方案.我知道,由于我对物理学的了解,结果是错误的.但是,这样做时不会出现错误.这是我将近两年来一直在进行故障排除的问题,因为我决心要解决它,但是我已经开始失去它了. Matlab论坛不希望解决这个问题,Matlab的工作人员仅在一周前在我4个月前发表的有关此问题的帖子上提出了建议.他的建议是它可能与我的持久变量定义有关,但这是我唯一可能的线索.如果您认为自己知道解决方案,请继续看一下.由于这是一个物理模拟,所以我想将其发布在Stack Excahnge上,但是一个mod删除了我的帖子,因为它是计算机科学",在我看来这太严格了,因为这两者都需要很多时间才能理解正在执行的操作这里直觉地说.

So we know where the error occurs, but I have been unable to resolve it nonetheless. This is an error that has also been inconsistent too. It does not always appear when I run the main script "collisions.m" but happens only when certain things get altered. Some examples: I start with too many electrons/particles, usually 1000+. Or I try to input a non-zero electric field. The electric field function is still being referenced but it is zero (Here comes the strange part). The reason I did this is because although the error goes away, the ode solver does not compute even close to the correct solutions I am looking for. I know for a fact that the results are wrong due to my knowledge of physics. However, when it does this, it does not give an error. This is the problem I have been troubleshooting for almost 2 years because I have been determined to solve it but I am starting to lose that. Matlab forums does not wish to address the this and a Matlab staff member only gave a suggestion a week ago on a post I made 4 months ago about this. His suggestion was that it may have something to due with my persistent variable definition but that is the only possible lead I have. If you think you know a solution, please go ahead a take a look. Since this is a Physics simulation I would like to post this on Stack Excahnge, however a mod deleted my post because it was "computer science" which is kinda too strict in my opinion since it takes a lot of both to understand what is being done here intuitively speaking.

我已经尝试过的故障排除方法:

Troubleshooting methods I have already been through:

  1. 首先,如果您查看 Matlab 中的文档,显示了定义ODE集的特定语法示例.按照Matlab的语法,它们分别定义每个方程式,然后使用定义定义方程式的向量.当我尝试这种语法时,求解器要么无法正确求解方程式,要么给了我输入参数过多"错误.我完全运行它的方法是在"bdipodefun.m"中的一行上直接定义每个方程.只有该语法有效,并且在我的脑海中没有充分的理由说明为什么会这样,因为在求解器的输入参数之一中使用的定义是相同的.即使在更简单的代码中也使用Matlab建议的语法,会使ode解决方案不正确.
  2. 我尝试了Matlab必须提供的所有ode求解器.相同的问题仍然存在,或者根本无法解决方程式.
  3. 我尝试从头开始重新编码整个模拟.我发现即使在更简单的代码中也仍然会发生此错误.
  4. 如果没有电场,则方程求解器也无法正确求解系统.我发现,如果我创建一个E字段函数,甚至只是在文件中将其定义为零,则系统可以正确解决.为何发生这种情况绝对没有道理.
  1. First if you look at the documentation from Matlab, it shows a specific syntax example to define the set of ODEs. In Matlab's syntax, they define each equation individually and then the vector of equations using the definitions. When I tried this syntax, the solver either did not solve the equations correctly, or it gave me the "too many input arguments" error. The way I made it run at all was to define every equation outright on a single line in "bdipodefun.m". Only that syntax worked and there is no good reason in my mind why this is the case because the definition that is used in one of the input arguments for the solver is the same. Using the Matlab recommended syntax even in simpler code, makes the ode solution incorrect.
  2. I tried all ode solvers Matlab has to offer. The same issues persist or it cannot solve the equations at all.
  3. I tried re-coding the entire simulation from scratch. I have found that this error still occurs even in more simpler codes.
  4. Equation solver will also not solve the system correctly if there is no E-field. I found that if I create an E-field function and even just define it as zero within the file, the system solves correctly. It absolutely makes no sense as to why this is occurring.

这里是代码中每个文件的作用的描述:

Here is a description of what each file does in the code:

  • "collisionsmain.m" =引用其他文件的主脚本
  • "B_test.m" =冲突引用的B字段功能文件main
  • "E_test.m" =冲突引用的E字段功能文件main
  • "engen.m" =根据麦克斯韦概率分布曲线为电子产生能量
  • "maxdis.m" = engen使用的麦克斯韦分布函数
  • "engen.m" =根据麦克斯韦定律为电子产生能量
  • "posgen.m" =在球体上生成随机的初始位置"bdipodefun.m" = ODE求解器在碰撞中引用的ODE函数集main

文件链接: https://drive.google .com/drive/folders/19eJrgWYL4LQFwTY-VwguCCkta-pimZlL?usp = sharing

否则,如果时间太长,则任何有关故障排除的建设性建议将不胜感激.

Otherwise if it is too long, any constructive suggestions for troubleshooting would be greatly appreciated.

推荐答案

我不理解代码,因为它既复杂又庞大.无论如何,我跟踪了错误并找到了问题的根源.该错误来自bdipuniodefun.m函数中已发送到Ex, Ey, Ez的参数数量. Ex, Ey, Ez函数接收3个参数,而它们只能处理一个参数.

I didn't understand the code because it is complicated and big. Anyway, I tracked the error and find the source of the issue. The error comes from the number of parameters that have been sent to Ex, Ey, Ez in bdipuniodefun.m function. Ex, Ey, Ez functions receives 3 parameters while they can handle one parameter only.

以下代码未发送错误,但显示了结果.

The following code didn't send error and it shows the results.

bdip_r1 = [s(4); s(5); s(6)];
bdip_r2 = (q/m_e) * (Ex(s(1)) + s(5)*Bz(s(1),s(2),s(3))- s(6)*By(s(1),s(2),s(3)));
bdip_r3 = (q/m_e)*(Ey(s(1)) + s(6)*Bx(s(1),s(2),s(3)) - s(4)*Bz(s(1),s(2),s(3)));
bdip_r4 = (q/m_e)*(Ez(s(1)) + s(4)*By(s(1),s(2),s(3)) - s(5)*Bx(s(1),s(2),s(3)));

bdip =[bdip_r1;bdip_r2;bdip_r3;bdip_r4];

这篇关于“输入参数过多";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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