i want to find k for different values of w using determinants, after that i want to find y2 for the different values but y2 cannot be executed
1 回表示 (過去 30 日間)
古いコメントを表示
%finding k for different values of w
syms k
c44=44;
i=sqrt(-1);
w=1:3;
y1=zeros(1,length(w));
s=sym(zeros(1,length(w)));
p=sym(zeros(1,length(w)));
q=sym(zeros(1,length(w)));
y=sym(zeros(1,length(w)));
for j=1:length(w)
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(j)=vpasolve(z,k);
disp(y)
y1=real(y);
%relation between y1(or value of k) and w
y2(j)=w/y1(j);
end
0 件のコメント
採用された回答
Steven Lord
2023 年 11 月 9 日
w is a vector.
w=1:3
y1(j) is a scalar. For purposes of this example I'll show a "dummy" y1 vector.
y1 = [4 5 6];
j = 1;
y1(j)
What do you get when you divide w by y1(j)? What size is that result?
result = w/y1(j)
y2(j) is also a scalar (a 1-by-1 array.)
Can you stuff a 1-by-3 vector into a 1-by-1 array? To use a metaphor, can you fit three eggs into the same cup of an egg carton (without scrambling them)? No, you can't. So MATLAB throws an error when you try.
Perhaps you meant to divide w(j) by y1(j)?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!