フィルターのクリア

i want to find k for different values of w, k will be obtained from the determinant of the matrix ,this is a sample my actual code is 8 by 8 matrix ,please help

1 回表示 (過去 30 日間)
%finding k for different values of w
syms k
c44=44;
i=sqrt(-1);
for w=1:3
s(j)=c44*exp(k)*w(j);
p(j)=c44/w(j);
q(j)=c44+w(j)*i/k^2;
A=[c44*s(j) 2;p(j) q(j)];
z=det(A);
y=vpasolve(z,k);
end
Array indices must be positive integers or logical values.

採用された回答

Walter Roberson
Walter Roberson 2023 年 11 月 4 日
You are looping for w but you are using j as your index. The default value for the variable j is sqrt(-1) so you are trying to index by the imaginary constant.
Note also that when you for w=1:3 that at any point inside the loop, w will be a scalar. But your loop has w(j) inside the loop whcih is an attempt to index the scalar by j . In context, with those assignments, the only way those assignments could work is if j is either 1 or true or false or []
  4 件のコメント
Walter Roberson
Walter Roberson 2023 年 11 月 4 日
you do not ask it to display answers. Also you overwrite all of y each iteration so that at the end of the loop y would hold only the result from the final iteration.
Rosalinda
Rosalinda 2023 年 11 月 4 日
thank you so much for your time

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by