# Incorrect dimensions for raising a matrix to a power

21 views (last 30 days)
Zihan Liu on 24 Sep 2021 at 5:00
Commented: Zihan Liu on 24 Sep 2021 at 5:25
How can I solve this problem
x=0:0.01:4
y=1/(sqrt((1-x.^2)^2+(4*0.01^2*x.^2)))
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 '.^'.

KSSV on 24 Sep 2021 at 5:05
x=0:0.01:4
x = 1×401
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
y=1./(sqrt((1-x.^2).^2+(4*0.01^2*x.^2)))
y = 1×401
1.0000 1.0001 1.0004 1.0009 1.0016 1.0025 1.0036 1.0049 1.0064 1.0082 1.0101 1.0122 1.0146 1.0172 1.0200 1.0230 1.0263 1.0298 1.0335 1.0374 1.0417 1.0461 1.0509 1.0558 1.0611 1.0667 1.0725 1.0786 1.0850 1.0918
Zihan Liu on 24 Sep 2021 at 5:25
Thank you !

VBBV on 24 Sep 2021 at 5:05
y=1./(sqrt((1-x.^2).^2+(4*0.01^2*x.^2)))
As mentioned in the error comment use the element wise power
Zihan Liu on 24 Sep 2021 at 5:25
Thx it works !