MATLAB Answers

Incorrect dimensions for raising a matrix to a power

조회 수: 6(최근 30일)
Zihan Liu
Zihan Liu 2021년 9월 24일
댓글: Zihan Liu 2021년 9월 24일
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 '.^'.

답변(2개)

KSSV
KSSV 2021년 9월 24일
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

VBBV
VBBV 2021년 9월 24일
y=1./(sqrt((1-x.^2).^2+(4*0.01^2*x.^2)))
As mentioned in the error comment use the element wise power

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by