简体   繁体   中英

Error when plotting in Octave

In Octave 4.0.2 I have defined a function S as follows:

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:

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."

What is going on?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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