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
beta, zeta1, zeta2 are constants.
r is defined as logspace(-2, 2, 4001)
0 个评论
采纳的回答
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
%% 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 个评论
Sam Chak
2024-1-18
@Yuvraaj Pasumarthy, From the plot, I guess that this related to a Base Excitation model.
更多回答(1 个)
Selena Mastrodonato
2024-1-18
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)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!