How to handle a variable inside matrix without using syms toolbox?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
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]...
*[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
Walter Roberson
2021년 8월 2일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Number Theory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!