I am writing a code to find the k in the state feedback, but there's an error
A=[0 0 0 217.28; 0 0 127.33 0; 0 -1 -3.73 0.97; -1 0 0.97 -3.73]; %4*4
B=[0 0 -.38 -1.39; 0 0 -1.18 0.29].'; %4*2
C=[1 0 0 0]; %1st row of C
D=zeros(1, 2);
% Desired pole locations
desired_poles = -1 * ones(1, size(A, rank(B))); % All poles at -1
% Calculate the feedback gain matrix K using pole placement
k = place(A, B, desired_poles)
% Create the closed-loop system
Aclosed = A - B * k;
Bclosed = B;
Cclosed = C;
Dclosed = D;
% Check the poles of the closed-loop system
closed_loop_poles = eig(Aclosed);
disp('Poles of the closed-loop system:');
disp(closed_loop_poles);
I was expecting it to display the k & closed_loop_poles. Instead I get:
Error using [place](matlab:matlab.internal.language.introspective.errorDocCallback('place'))
The "place" command cannot place poles with multiplicity greater than rank(B).
I noticed a potential issue in your code. The line size(A, rank(B)) may not return the expected size for desired_poles. The correct size should be the number of columns in matrix B, as you want one pole for each input. Replace this line: desired_poles = -1 * ones(1, size(A, rank(B))); With: desired_poles = -1 * ones(1, size(B, 2));
This ensures that desired_poles has the correct size based on the number of columns in matrix B. After making this change, your code should work as intended for pole placement in state feedback.