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!