Filter löschen
Filter löschen

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 Ansicht (letzte 30 Tage)
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)

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by