clc; %clear console clear; %clear workspace close all; %close all figures pkg load control %remove if using MATLAB %real system Cf = 10e-3; %mF Lf = 5e-3; %mH A = [0 1/Cf; %system matrix -1/Lf 0]; B = [0;1/Lf]; %input matrix C = [1 0]; %output matrix D = [0]; %feedthrough matrix %task 1d) poles = [...]; %% <= change here to tune observer speed L = ...; %%task 1e) %A_full = [...]; %from task c) %x0 = [...]; % %[Y,T,X] = initial(ss(A_full,zeros(4,1)),x0,.2,5e-6); %subplot(211); %plot(T,X(:,1),'r;voltage;','LineWidth',2, % T,X(:,3),'b;voltage-est;','LineWidth',2) %subplot(212); %plot(T,X(:,2),'r;current;','LineWidth',2, % T,X(:,4),'b;current-est;','LineWidth',2) %%task 1f) %%system assumed by observer %Cf_obs = 10e-3; %mF %Lf_obs = 5e-3; %mH %A_obs_ol = [0 1/Cf_obs; %system matrix observer open loop % -1/Lf_obs 0]; %B_obs = [0;1/Lf_obs]; %input matrix %C = [1 0]; %output matrix %D = [0]; %feedthrough matrix % %L = place(A_obs_ol',C',poles)'; %A_full2 = [A_obs zeros(2,2) ; L*C A-L*C]; % %figure %[Y,T,X] = initial(ss(A_full2,zeros(4,1)),x0,.2,5e-6); %subplot(211); %plot(T,X(:,1),'r;voltage;','LineWidth',2, % T,X(:,3),'b;voltage-est;','LineWidth',2) %subplot(212); %plot(T,X(:,2),'r;current;','LineWidth',2, % T,X(:,4),'b;current-est;','LineWidth',2)