Extracting multiple data in a MATLAB matrix

Click For Summary
SUMMARY

The discussion focuses on extracting numerical data from multiple text files (g0001.txt to g0060.txt) into a MATLAB matrix where each element is an array. The desired matrix format is 1 x 60, with each element representing the data from individual text files. The user prefers using a cell array for storage and intends to plot the extracted data against another array. For importing data from text files, the official MATLAB documentation is referenced.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of cell arrays in MATLAB
  • Knowledge of data visualization techniques in MATLAB
  • Basic experience with importing data from text files in MATLAB
NEXT STEPS
  • Review MATLAB's cell array documentation for efficient data storage
  • Learn about MATLAB's plotting functions for visualizing data
  • Explore the MATLAB functions for reading text files, specifically 'readmatrix' and 'textscan'
  • Investigate best practices for managing large datasets in MATLAB
USEFUL FOR

Data analysts, MATLAB users, and researchers looking to efficiently extract and visualize data from multiple text files in MATLAB.

1994Bhaskar
Messages
134
Reaction score
0
Hey everyone. I want to extract numerical data from files let's say g0001.txt to g0060.txt and store it in a matrix with each element is an array.
like this:
M=[g1() g2() g3() ...g60()]
matrix order can be 1 x 60 , i.e. to say 1 row and 60 columns and each element is an array which stores the entire data from g000n.txt. like i want data from g0001.txt in g1() and g0002.txt in g2() and so on.
Also later on i want plot each of these elements with respect to another array by accessing them each.
Each of these .txt files will have around 200 float values.
 
Physics news on Phys.org
If you want each set of data to be an element of a larger "thing", then you should put them into a cell array or structure (I prefer the former).

For info and the available functions for importing data from text files, check out this doc page:
http://www.mathworks.com/help/matlab/text-files.html
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 7 ·
Replies
7
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 2 ·
Replies
2
Views
5K