MATLAB: Can’t I solve this, it’s simple. (Incorrect dimensions…. use .^) (I did then it says Invalid Operator…….)

invalidMATLABoperator

>> [x,y]=meshgrid(1:1:exp(5), -3:0.01:3)
>> z=((x+1)^y)-(x^y)
Error using ^ (line 51)
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a
scalar. To perform elementwise matrix powers, use '.^'.
>> z=((x+1)^.y)-(x^y)
z=((x+1)^.y)-(x^y)
Error: Invalid use of operator.

Best Answer

This works fine:
z = ((x+1).^y)-(x.^y);
You should read a bit on the difference between array and matrix operations.