Effacer les filtres
Effacer les filtres

I am writing relatively long expression and it's showing me "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mis-matc

1 vue (au cours des 30 derniers jours)
wn = 196570;
r = 6351.43;
chi = 0:1:2;
phim = 1;
ke = 1.134;
w = 1/(wn.^2*sqrt(1+(r.*chi.)^2))*sqrt((1-(1+2*phim.*r.)*chi.)^2+((1+ke.^2)*r.*chi.+2*phim.*chi.-r.*chi.^3)^2);
plot(chi,w)

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Oct 2022
not (r.*chi.)^2 but (r.*chi).^2
  3 commentaires
Walter Roberson
Walter Roberson le 14 Oct 2022
w = 1 ./ (wn.^2 .* sqrt(1+
(r.*chi).^2)) .* sqrt((1-(1+2*phim.*r).*chi).^2 + ((1+ke.^2) .* r .* chi + 2*phim.*chi - r.*chi.^3).^2);
The period is not a suffix. A.*B is not parsed as (A.)*B with trailing period meaning something like "treat the result of the previous expression as an element-by-element matrix for whatever operation is next". Instead, the character pair .* is an operator that is different than the * operator, and ./ is an operator that is different than / operator, and .^ is a different operator than ^ (and .\ is an obscure operator different than \ )

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by