Azzera filtri
Azzera filtri

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

Risposta accettata

Walter Roberson
Walter Roberson il 14 Ott 2022
not (r.*chi.)^2 but (r.*chi).^2
  3 Commenti
Walter Roberson
Walter Roberson il 14 Ott 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 \ )

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by