MATLAB Answers

How to handle a variable inside matrix without using syms toolbox?

조회 수: 4(최근 30일)
Vinothkumar Sethurasu
Vinothkumar Sethurasu 2021년 6월 24일
댓글: Walter Roberson 2021년 8월 2일
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.

채택된 답변

Alan Stevens
Alan Stevens 2021년 6월 24일
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]...
% 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
M(w+1,:) = [w^6,w^5,w^4,w^3,w^2,w,1];
coeffs = M\V;
r = roots(coeffs);
-0.0000 0.0000 0.0175 0.0000 -29.1858 0.0000 0
0 -195.4814 195.4814 -41.8216 41.8216 0.0000
% Check that the polynomial is, in fact, zero at the calculated values
for i = 1:7
F = f(r(w));
-1.7339e-27 -1.7339e-27 -1.7339e-27 -1.7339e-27 -1.7339e-27 -1.7339e-27 -1.7339e-27
  댓글 수: 17

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by