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.
where is the mistake?
^is the matrix power operator,mpower. The syntaxA^nattempts to raise the (square) matrixAto thenth power. This will obviously fail ifAis not a square matrix (in your example, it is a vector).Since your username includes
engand you’re posting about MATLAB, I assume that you are an engineering student – your introductory math course should have covered matrix math, and whyA * Ais only defined for squareA.You actually want the scalar operator
.^, as inA.^n. This raises each element ofAto thenth power.