simulink to workspace indexing error

2 vues (au cours des 30 derniers jours)
Tina Barsoumian
Tina Barsoumian le 2 Mar 2020
Hi, last week I was running the same simulink model and was receiving an array that was very large. This week I am trying to export data but the output is only a 1x1 double timeseries. I didn't change anything other than the data I am extracting so I'm not sure what could have changed in my simulink model. I have attached the file and here is the code I am using to extract data
When I run the code I get the error "Index in position 2 exceeds array bounds (must not exceed 1)."
RBE500_Week5_Model_barsoumian_tina
%defining variables to plot
EE = out.EE_Position_Velocity;
Position = EE(:,2:4);
LVelocity = EE(:,5:7);
AVelocity = EE(:,8:10);

Réponses (1)

Sai Sri Pathuri
Sai Sri Pathuri le 5 Mar 2020
In your code, EE is a timeseries data with following properties
Common Properties:
Name: ''
Time: [51x1 double]
TimeInfo: [1x1 tsdata.timemetadata]
Data: [51x9 double]
DataInfo: [1x1 tsdata.datametadata]
The variable has two fields - Time and Data as shown below
To extract data, you may use the dot indexing
Position = EE.Data(:,1:3);
LVelocity = EE.Data(:,4:6);
AVelocity = EE.Data(:,7:9);

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by