Effacer les filtres
Effacer les filtres

identify model parameters and data (g = Gm).

111 vues (au cours des 30 derniers jours)
meoui
meoui le 25 Sep 2024 à 9:47
Commenté : Umar le 26 Sep 2024 à 2:03
I have a problem, namely to identify model parameters and data (g = Gm).
I've done it in my notebook, but I want to write a matlab script for this and I'm struggling on how to write the matrix G the right way in matlab.
This is how I write G in my notebook:
1111000000000000
0000111100000000
0000000011110000
0000000000001111
1000100010001000
0100010001000100
0010001000100010
0001000100010001

Réponses (1)

Umar
Umar le 25 Sep 2024 à 10:02

Hi @meoui ,

To create the matrix G in MATLAB, you can use either a direct approach by manually entering the values or utilizing functions to generate the matrix if it follows a specific pattern. Based on the provided binary representation of here is how you can define it in MATLAB:

% Define the matrix G
G = [
  1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0;
  0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0;
  0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0;
  0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0;
  1 0 0 1 0 0 1 0 1 0 0 1 0 1; 
  ...
];
% Display the matrix G
disp(G);

So, in this script:

*The G matrix is constructed using square brackets [], with each row separated by semicolons ;

*Each binary digit (either `1` or `0`) corresponds to an entry in the matrix.

*Make sure that all rows have consistent lengths (16 columns in this case) to maintain matrix integrity.

So, the provided matrix appears to be of size 8 times 16. Make sure that your application context supports this size, particularly if it relates to coding theory where dimensions may affect performance. By default, MATLAB treats numbers as double precision. However, since you're working with binary data, you might want to convert it into logical values for certain applications:

G = logical(G); % Convert to logical if needed

For more information on function logical, please refer to

https://www.mathworks.com/help/symbolic/sym.logical.html

Depending on what you plan to do with this matrix (e.g., performing operations like multiplication or inversion), make sure that you understand how MATLAB handles matrices and vectors, especially in terms of dimensions and operations.

If you have any additional requirements or need further assistance with specific operations involving this matrix, feel free to ask!

  3 commentaires
Umar
Umar le 25 Sep 2024 à 15:22

Hi @meoui,

After doing analysis of your code, here are the corrections needed along with an explanation:

Matrix C Definition: The variable G is referenced for matrix C, but it is not defined in the provided code snippet. Ensure that G is defined prior to this line.

Matrix D Size: The size of matrix D should match the output dimension of C and the input dimension of B. If C has more than one row or if it doesn't match the expected dimensions, it could lead to errors.

Title Formatting: While not strictly necessary, using proper MATLAB functions for titles can enhance clarity.

Here is a corrected version of your script with considerations for defining G and ensuring all matrices are appropriately sized:

% Define G matrix (ensure G is appropriately sized)
G = eye(8); % Example definition; adjust as necessary
% Define state-space matrices
A = eye(8); % Identity matrix 8x8
B = ones(8, 1); % Column vector 8x1 with all elements 1
C = G; % Using G as output matrix C
D = zeros(size(C, 1), size(B, 2)); % D matrix size must match C's
    output size
% Create state-space model
sys = ss(A, B, C, D);
% Analyze system response
figure; % Open a new figure window
step(sys); % Step response analysis
title('Step Response of State-Space System'); % Add title to plot
grid on; % Add grid for better visualization

For more information on State space model function, please refer to

https://www.mathworks.com/help/control/ref/ss.html

Please see attached.

Your example uses an identity matrix for G. Depending on your application, you may want to define G differently to reflect your specific system dynamics. Also, before running the script, ensure that all matrices conform to expected dimensions: A should be n x n (in this case, 8x8), B should be n x m (where n=8 and m=1 here), C should be p x n (where p is the number of outputs) and D should be p x m. This revised script should work correctly within MATLAB, allowing you to analyze the step response of your defined state-space system effectively.

Hope this answers your question.

Umar
Umar le 26 Sep 2024 à 2:03
Hi @meoui,
Please let me know if you need any further assistance.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by