Compose-3020: Read CAE Data in OML
- Observe the hierarchy of CAE file using readvectorbuilder.
- Read CAE Data using readvector.
- Read CAE Data using readmultvectors.
Observe Hierarchy Using readvectorbuilder
readvectorbuilder is a utility tool that reads CAE results/data files supported byCompose. It helps you create the right readvector()and readmultvectors() commands. The tool opens the readvector utility dialog that can be used to select results files and navigate into the subcases, time steps, types, requests, and components contained in the selected file. Upon making your selections and selecting Print, the appropriate OML command (using either the readvector or readmultvectors command) is displayed.
-
Reading values across all time steps.
-
Reading multiple requests and components on a selected time step.
Read CAE Data Using readvector
In this second exercise, you will design a moving average filter and filter the data read from a CAE file.
-
Plot the original data
-
Design a simple moving average filter.
A simple moving average can be implemented in Compose using the filter command:
% moving average filter b = 0.2*ones(1,5); a = 1; output = filter(b,a,input);
-
Compare the results between the original data and filtered one.
Use the script below to plot and check the difference between the original data, which extracted from the ANGACC file and the filtered data:
y = readvector('ANGACC',2,1,1); plot(y,'g--'); % moving average filter b = 0.2*ones(1,5); a = 1; y2 = filter(b,a,y); hold on; plot(y2,'r:'); legend('Original data','Filtered data'); title('readvector Demo'); xlabel('Time(ms)'); ylabel('Angular Acceleration(rad/s2)');
The plot is shown below:
Read CAE Data Using readmultvectors
- The first column contains the Type
- The second column contains the Request
- The third column contains the Component
- The fourth column contains the data vector specified by the information in the corresponding first three columns.
- Each row contains a different data set. You can then use the extract function to extract the interested data afterwards.
function y = SMA(x)
b = 0.2*ones(1,5);
a = 1;
y = filter(b,a,x);
end
filePath = '<installation_dir>\tutorials\ANGACC';
y = readmultvectors(filePath);
% extract interested data then do the moving average filtering
y_LT1 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3 -
LOWER TORSO','Res. ang. acc.'));
y_LT2 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3 -
LOWER TORSO','X-comp. ang. acc.'));
y_LT3 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3 -
LOWER TORSO','Y-comp. ang. acc.'));
y_LT4 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3 -
LOWER TORSO','Z-comp. ang. acc.'));
x = extract(y,'Time','Time','Time');
% do the plot
plot(x,y_LT1,x,y_LT2,x,y_LT3,x,y_LT4);
xlabel('Time(ms)');
ylabel('Angular Acceleration(rad/s2)');
title('50th% Hybrid3 - LOWER TORSO');
legend('Res. ang. acc.','X-comp. ang. acc.','Y-comp. ang.
acc.','Z-comp. ang. acc.');
An example of extracting multiple data from this file can be found in the OML script located in <installation_dir>/tutorial/readvector_demo.oml.