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 '.^'.

조회 수: 1 (최근 30일)
clear
clc
wn = 150;
w = 3.142;
wb = 0.50;
req = 2.75E09;
rl = 2e09;
d = 390E-12;
omega = 0:0.02:20;
b = 0.0111;
cp = 22.74E-09;
ke = 1.286;
meff = 0.0025;
r = wn*req*cp;
den1 = (1-(1+2*b*r)*(omega.^2))^2;
den2 = ((1+ke)*r*omega+2*b*omega-r*omega.^3)^2;
wnum = 1/(wn^2*sqrt(1+(r*omega)^2));
vnum = meff*req*d*wn*omega;
Pout = meff*b*r*ke*(omega.^2)*w^4
Hi all,
I'm trying to plot wnum, vnum and pout against omega but, I'm getting the error stated in the title. I do use the '.^' but, i'm still getting the same error, is there a workaround i could use?
Many thanks,
Zain

채택된 답변

Jon
Jon 2020년 12월 1일
편집: Jon 2020년 12월 1일
You need to use .^ for all of your powers. Also ./ for your divide, like this
clear
clc
wn = 150;
w = 3.142;
wb = 0.50;
req = 2.75E09;
rl = 2e09;
d = 390E-12;
omega = 0:0.02:20;
b = 0.0111;
cp = 22.74E-09;
ke = 1.286;
meff = 0.0025;
r = wn*req*cp;
den1 = (1-(1+2*b*r)*(omega.^2)).^2;
den2 = ((1+ke)*r*omega+2*b*omega-r*omega.^3).^2;
wnum = 1 ./(wn.^2*sqrt(1+(r*omega).^2));
vnum = meff*req*d*wn*omega;
Pout = meff*b*r*ke*(omega.^2)*w.^4

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by