简体   繁体   English

在八度绘制时出错

[英]Error when plotting in Octave

In Octave 4.0.2 I have defined a function S as follows: 在Octave 4.0.2中,我定义了一个函数S,如下所示:

S = @(x) (Y(k)+((Y(k+1)-Y(k))/h(k)-(2*M(k)+M(k+1))*h(k)/6)*(x-X(k))+M(k)*(k-X(k))^2/2+(M(k+1)-M(k))*(x-X(k))^3/(6*h(k)))

When I call it to evaluate a number in the interval [X(k), X(k+1)] I get the result I expect, but when I try plotting it with the command: 当我调用它来评估区间[X(k),X(k + 1)]中的数字时,我得到了期望的结果,但是当我尝试使用以下命令对其进行绘制时:

fplot(S, [X(k), X(k+1)]); hold on;

I get the error "error: for A^b, A must be a square matrix. Use .^ for elementwise power." 我收到错误消息“错误:对于A ^ b,A必须为方阵。对于元素功率使用。^。”

What is going on? 到底是怎么回事?

好吧,我发现将函数传递给fplot时,它必须能够获取输入向量并返回输出向量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM