Azzera filtri
Azzera filtri

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

12 visualizzazioni (ultimi 30 giorni)
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)

Risposta accettata

Sam Chak
Sam Chak il 18 Gen 2024
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 Commenti
Yuvraaj Pasumarthy
Yuvraaj Pasumarthy il 20 Gen 2024
@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.

Accedi per commentare.

Più risposte (1)

Selena Mastrodonato
Selena Mastrodonato il 18 Gen 2024
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)

Community Treasure Hunt

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

Start Hunting!

Translated by