How can I deal with the content of a generalized matrix?

2 visualizaciones (últimos 30 días)
Mario
Mario el 30 de Mayo de 2024
Editada: Mario el 25 de Jun. de 2024
I would like to operate with a generalized matrix / generalized system getting the real and imaginary parts of its elements, but the use of real tunable parameters is not compatible.
a = realp('a',1);
b = realp('b',-0.5);
D = a+1i*b;
sys = ss([],[],[],D)
Generalized continuous-time state-space model with 1 outputs, 1 inputs, 0 states, and the following blocks: a: Scalar parameter, 1 occurrences. b: Scalar parameter, 1 occurrences. Type "ss(sys)" to see the current value and "sys.Blocks" to interact with the blocks.
real(sys.D)
Incorrect number or types of inputs or outputs for function real.
I know I can get the value, but I looking for the expression with the tunable parameter. I also know that symbolic computing could be an option, but it is not compatible with state-space dynamic systems.

Respuestas (1)

MULI
MULI el 18 de Jun. de 2024
Hi Mario,
I understand that you are facing an issue in handling complex numbers to separate the real and imaginary parts within a control system model.
Below MATLAB Code helps in modifying these values:
% Define the real and imaginary parts as tunable parameters
a = realp('a', 1); % Real part with initial value 1
b = realp('b', -0.5); % Imaginary part with initial value -0.5
% Combine 'a' and 'b' to form a complex number for the D matrix in a state-space model
D = a + 1i*b
% Create the state-space model with this D matrix
sys = ss([], [], [], D);
% Update the values of 'a' and 'b'
sys.Blocks.a.Value = 2; % New value for 'a'
sys.Blocks.b.Value = -1; % New value for 'b'
% Display the current D matrix of the system
disp('Updated D matrix:');
disp(sys.D);
By executing these statements, the values of the parameters `a` and `b` within your system model `sys` can be modified programmatically.
You may refer this documentation link for more information on properties of “ss” (state space model) function.
Hope this clears your query!
  1 comentario
Mario
Mario el 25 de Jun. de 2024
Editada: Mario el 25 de Jun. de 2024
Hi MULI,
Thanks for your kind answer. My issue goes an step further. Imagine you operate with sys, connecting it with other state space systems and them, you want to obtain the real and imaginary part of some item and see the dependences with the realp parameters. A priori, you do not know that D is a+j*b.
% Define the real and imaginary parts as tunable parameters
a = realp('a', 1); % Real part with initial value 1
b = realp('b', -0.5); % Imaginary part with initial value -0.5
% Combine 'a' and 'b' to form a complex number for the D matrix in a state-space model
D = a + 1i*b
Generalized matrix with 1 rows, 1 columns, and the following blocks: a: Scalar parameter, 1 occurrences. b: Scalar parameter, 1 occurrences. Type "double(D)" to see the current value and "D.Blocks" to interact with the blocks.
% Create the state-space model with this D matrix
sys_1 = ss([], [], [], D);
sys_1.u = 'in1';
sys_1.y = 'out1';
% Create a second state-space model: y = (1/s+1)*u;
sys_2 = ss(0,1,1,1);
sys_2.u = 'out1';
sys_2.y = 'out2';
sys_2.StateName = 'x2';
% Connect both systems
sys_3 = connect(sys_1,sys_2,'in1','out2');
% Numeric: Getting real part of some item
ss(sys_3).D(1)
ans = 1.0000 - 0.5000i
% Getting dependence of a and b in the real part of some item
real(sys_3.D(1))
Incorrect number or types of inputs or outputs for function real.
Thank you again for your time.

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by