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 次查看(过去 30 天)
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)

采纳的回答

Walter Roberson
Walter Roberson 2022-10-14
not (r.*chi.)^2 but (r.*chi).^2
  3 个评论
Walter Roberson
Walter Roberson 2022-10-14
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 \ )

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by