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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%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 commentaires
Réponse acceptée
Steven Lord
le 9 Nov 2023
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)?
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!