What does "invalid use of operator" mean here? I add parenthesis, that becomes error, i remove it and then the operator becomes the error...

2 次查看(过去 30 天)
sqrt((1-(beta^2+4*zeta1*zeta2*beta)*(r.^2)).^2 + 4*(r.^2).*(zeta1+zeta2*beta-zeta1*beta^2*(r.^2)).^2)/sqrt({1-[(1+mu)*beta^2+1+4*zeta1*zeta2*beta]*(r.^2) + (beta^2)*(r.^4)}.^2 + 16*(zeta1 +zeta2*beta)*r. - [zeta1*(1+mu)*beta^2 + zeta2*beta]*(r.^3)).^2
Invalid use of operator.
beta, zeta1, zeta2 are constants.
r is defined as logspace(-2, 2, 4001)

采纳的回答

Sam Chak
Sam Chak 2024-1-18
I didn't check the correctness of your equation. However, I have fixed some parentheses and added a dot division.
%% Display the equation
syms beta zeta1 zeta2 r mu
X = sqrt((1 - (beta^2 + 4*zeta1*zeta2*beta)*(r^2))^2 + 4*(r^2)*(zeta1 + zeta2*beta - zeta1*beta^2*(r^2))^2)/sqrt((1-((1+mu)*beta^2+1+4*zeta1*zeta2*beta)*(r^2) + (beta^2)*(r^4))^2 + 16*(zeta1 +zeta2*beta)*r - (zeta1*(1+mu)*beta^2 + zeta2*beta)*(r^3))^2
G = 
%% Plot
r = logspace(-2, 2, 4001);
beta = 2;
zeta1 = sqrt(3)/2;
zeta2 = 1/sqrt(2);
mu = 0.1;
X = sqrt( (1 - (beta^2 + 4*zeta1*zeta2*beta)*(r.^2)).^2 + 4*(r.^2).*(zeta1 + zeta2*beta - zeta1*(beta^2)*r.^2).^2)./sqrt((1 - ((1 + mu)*beta^2 + 1 + 4*zeta1*zeta2*beta)*(r.^2) + (beta^2)*(r.^4)).^2 + 16*(zeta1 + zeta2*beta)*r - (zeta1*(1 + mu)*beta^2 + zeta2*beta)*(r.^3)).^2;
semilogx(r, X), grid on
xlabel('r'), ylabel('X')
  2 个评论
Yuvraaj Pasumarthy
Yuvraaj Pasumarthy 2024-1-20
@Sam Chak Not exactly, I was trying to get a relation between mu and r without really changing up the reference equation which gives a relation b/w transmissibilty and r. i wanted to avoid a lengthy simplification. While the equation provided by you and the others help, I still need to make changes to the rest of the code to make that viable.
Any suggestions how I can go about it? I thank you for your answer for my old question from a few months ago, I was trying to play with that to get a solution for this.

请先登录,再进行评论。

更多回答(1 个)

Selena Mastrodonato
Hi Yuvraaj,
the invalid operator is here, the dot after r: sqrt((1-(beta^2+4*zeta1*zeta2*beta)*(r.^2)).^2 + 4*(r.^2).*
(zeta1+zeta2*beta-zeta1*beta^2*(r.^2)).^2)/sqrt({1-[(1+mu)*beta^2+1+4*zeta1*zeta2*beta]*(r.^2) + (beta^2)*(r.^4)}.^2 + 16*(zeta1 +zeta2*beta)*r. - [zeta1*(1+mu)*beta^2 + zeta2*beta]*(r.^3)).^2
Furthermore, some parenthesis seem wrong. This should work
sqrt((1-(beta^2+4*zeta1*zeta2*beta)*(r.^2)).^2 + 4*(r.^2).*(zeta1+zeta2*beta-zeta1*beta^2*(r.^2)).^2)/sqrt({1-[(1+m)*beta^2+1+4*zeta1*zeta2*beta]*(r.^2) + (beta^2)*(r.^4)}.^2 + 16*(zeta1 +zeta2*beta)*r - [zeta1*(1+m)*beta^2 + zeta2*beta]*(r.^3).^2)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by