How to handle a variable inside matrix without using syms toolbox?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vinothkumar Sethurasu
le 24 Juin 2021
Commenté : Walter Roberson
le 2 Août 2021
I have a application to have a variable inside a 2x2 matrix.
The matrix multiplication needs to be done with number 2x2 matrices with variables.
At the end, the final product matrix will have polynomial equatoins of the variable as its elements.
The roots of the polynomial equation at element (1,2), need to be evaluated.
The application need to be done without using syms toolbox.
0 commentaires
Réponse acceptée
Alan Stevens
le 24 Juin 2021
Are you looking for somethig like this;
f = @(w) [1,-0.1409*w^2;0,1]*[1,0;1/286.48,1]*[1,-0.05493*w^2;0,1]...
*[1,0;1/1793.55,1]*[1,-28.99*w^2;0,1];
%
% The sixth order polynomial of f(1,2) can be written as
% a*w^6 + b*w^5 +...+ f*w + g;
%
% Let w take on values 0, 1, 2..6
% Then you would have 7 equations in the 7 unknowns, a, b etc.
%
% Now you have a system of linear equations that can be solved
% for the unknowns using simple matrix division.
%
% The resulting values are the coefficients of the polynomial
% the roots of which can be found using the roots function.
for w = 0:6
P=f(w);
V(w+1,1)=P(1,2);
M(w+1,:) = [w^6,w^5,w^4,w^3,w^2,w,1];
end
coeffs = M\V;
r = roots(coeffs);
disp('Coefficients')
disp(coeffs')
disp('Roots')
disp(r)
% Check that the polynomial is, in fact, zero at the calculated values
disp('Check')
for i = 1:7
F = f(r(w));
disp(F(1,2))
end
17 commentaires
Walter Roberson
le 2 Août 2021
You already asked that at https://www.mathworks.com/matlabcentral/answers/888942-getting-different-results-from-function-handle-syms-for-a-same-equation-how-to-avoid-it?s_tid=srchtitle and you were answered.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Number Theory 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!