使用matlab进行错误绘图功能 [英] error plotting function using matlab
问题描述
我正在尝试绘制函数,但收到错误消息,并且由于我是新手,所以我不知道如何解决它.
I'm trying to plotting a function but I receive an error and since I'm a newbie I don't know how to fix it.
f=-10:0.001:10;
>> w=1/sqrt(4+(2*pi*f)^2);
??? Error using ==> mpower
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
哪里出了错?
推荐答案
^
是矩阵的幂运算符mpower
.语法A^n
尝试将(方)矩阵A
提高到第n
次幂.如果A
不是方阵(在您的示例中,它是一个向量),则显然将失败.
^
is the matrix power operator, mpower
. The syntax A^n
attempts to raise the (square) matrix A
to the n
th power. This will obviously fail if A
is not a square matrix (in your example, it is a vector).
由于您的用户名包括eng
,并且您正在发布有关MATLAB的信息,因此我假设您是一名工程专业的学生-您的数学入门课程应涵盖矩阵数学,以及为什么只为平方A
定义A * A
Since your username includes eng
and you're posting about MATLAB, I assume that you are an engineering student - your introductory math course should have covered matrix math, and why A * A
is only defined for square A
.
与A.^n
一样,您实际上需要标量运算符.^
.这会将A
的每个元素提高到n
次幂.
You actually want the scalar operator .^
, as in A.^n
. This raises each element of A
to the n
th power.
这篇关于使用matlab进行错误绘图功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!