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!