Kk = 
Why this function does not run
이전 댓글 표시
Hi,
I am trying to build a customized function for pole placement in order to achieve the same result as place(). But I can not use place due to assignment restriction. So here is my code. But I try to run it on matlab 2025a and it does not work and it takes forever to run. Please help.
clc;clear;close all;
% first the linearized matrix is included below, it is from the project 1.
m = 1;
g = 9.81;
J_x = 0.01;
J_y = 0.01;
J_z = 0.02;
psi = 0;
% the sate is given by state = [x,y,z,vx,vy,vz,phi,theta,psi,p,q,r];
A = [
0 0 0 1 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 g*sin(psi) g*cos(psi) 0 0 0 0;
0 0 0 0 0 0 -g*cos(psi) g*sin(psi) 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 0;
0 0 0 0 0 0 0 0 0 0 1 0;
0 0 0 0 0 0 0 0 0 0 0 1;
0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0];
B = [
0 0 0 0;
0 0 0 0;
0 0 0 0;
0 0 0 0;
0 0 0 0;
1/m 0 0 0;
0 0 0 0;
0 0 0 0;
0 0 0 0;
0 1/J_x 0 0;
0 0 1/J_y 0;
0 0 0 1/J_z];
C = zeros(4,12);
C(:,[1,2,3,9]) = eye(4); % here the observed outputs are x, y, z and psi
D = zeros(4,4); % here the d matrix is zero.
sys = ss(A,B,C,D); % this is the linearized system.
%%
poles = [-1.2 + 1.2*1j, -1.2 - 1.2*1j, -2.5, -3.0,...
-1.2 + 1.2*1j, -1.2 - 1.2*1j, -2.5, -3.0,...
-1.5 + 1.5*1j, -1.5 - 1.5*1j,...
-2+2*1j, -2-2*1j];
K = our_place(A,B,poles);
%% Local functions at the end of the script
function matrix = our_place(A,B,poles)
matrix = zeros(size(B,2),size(B,1));
matrix = sym("m",(size(matrix)));
s = sym("s");
S = s*eye(size(A));
left = det(S - (A-B*matrix)); %left hand side
right = poly2sym(poly(poles),s);
coefficientEquations = coeffs(expand(left - right), s, 'All') == 0;
solve(coefficientEquations, matrix(:));
end
댓글 수: 1
I cannot believe that you have to mimic the "place" function as part of your assignment because it's too hard to code. So: what is your assignment ?
At the moment, you try to solve a system of 12 polynomial equations (up to order 4) for 4*12 = 48 unknowns. This will not work.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!