# how to add a state space representation with identifiable parameters into a Matlab function or a any block?

2 visualizzazioni (ultimi 30 giorni)
kawsar il 11 Apr 2023
Risposto: Sam Chak il 12 Apr 2023
Hello everyone,
I found a way to add the disturbances into the state space representation but I don't know how create a block for that,
so I have created a matlab function with the code,
function [SOC,LOH] = statespace(PH2,Pgrid,d)
A = [1 1;1 1];
B = [0.0936 0.0936;-0.339 0];
C = [1 1;1 1];
D = 0;
K = [0.0936;0];
[SOC,LOH] = idss(A,B,C,D,K);
end
so the figure 1 is what i tried to do with the code above, and figure 2 is the state space representation with disturbances,  and the error is:  ##### 1 CommentoMostra NessunoNascondi Nessuno
Walter Roberson il 11 Apr 2023

Accedi per commentare.

### Risposte (1)

Sam Chak il 12 Apr 2023
I'm unfamiliar with your system (probably something to do with the state of charge of an energy storage system).
However, the Output Matrix , because it implies both outputs are the same .
Please check the matrix equations again.
A = [1 1; % state matrix
1 1];
B = [0.0936 0.0936; % input matrix
-0.339 0];
C = [1 1]; % output matrix
D = zeros(1, 2); % direct matrix
K = [0.0936; 0]; % disturbance matrix
sys = idss(A, B, C, D, K)
sys = Discrete-time identified state-space model: x(t+Ts) = A x(t) + B u(t) + K e(t) y(t) = C x(t) + D u(t) + e(t) A = x1 x2 x1 1 1 x2 1 1 B = u1 u2 x1 0.0936 0.0936 x2 -0.339 0 C = x1 x2 y1 1 1 D = u1 u2 y1 0 0 K = y1 x1 0.0936 x2 0 Sample time: unspecified Parameterization: FREE form (all coefficients in A, B, C free). Feedthrough: none Disturbance component: estimate Number of free coefficients: 12 Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Created by direct construction or transformation. Not estimated.
x0 = [0.1, 0.1];
Ts = 0.1;
% sys = idss(A, B, C, D, K, x0, Ts)
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!