Loading Results into MATLAB |
Top Previous Next |
When the simulation execution completes, you can use MATLAB-based HDFViewer application to view the results.
Just select an output from the list of recorded outputs to view it
However, in many cases it is not sufficient to just view the results. In such cases you need to perform the following steps to load the data into MATLAB.
NOTE: Before loading data into MATLAB, read How TimeLike Manages Simulation Results.
Steps to load data into MATLAB: (to make steps clear we use an example created in the Getting Started tutorial.
1.Start MATLAB. 2.Change the directory to the directory where the results are stored. 3.If the file is not too large, you can load the entire file with the command >> results = getalldata('run_1.h5');
4.If you want to load all data recorded for only one particular output, use the following command: >> results = getdata('run_1.h5', 1, 'u.onedmotion.position');
5.If you want to load data recorded for one particular output at some specified index, use the following command: >> results = getdataat('run_1.h5', 1, 'u.onedmotion.position', 3); % gets value at index 3.
This command is typically used for large data sets. For example, if the output that was recorded is of type Grid<double> and the recorded objects are grids of size 1024x1024, then one such grid takes up 8MB and if the entire data set contains data for 1000 sample points, then loading the entire data set for this output may exhaust computer's memory. NOTE: indexing this function uses is 0-based (i.e. to get the fourth element, use index 3)
Example MATLAB session: The result of the plot command executed in the MATLAB session above: |