Clear Filters
Clear Filters

Automatic naming of matrix

4 views (last 30 days)
Jake
Jake on 2 May 2016
Commented: Walter Roberson on 2 May 2016
Hi,
I have a cell matrix of 300,000 x 100 format. By using for loops, I want to make a new matrix every 10,000 rows while naming each different matrix automatically. For instance, a matrix that contains 1:10,000 from the original huge matrix will have something like matrix_1 as follows:
matrix_1 = [1:10,000,:];
matrix_2 = [10,001:20,000,:];
.
.
.
.
matrix_20 = [190,001:200,000,:];
Would you mind sharing your thoughts on this?
Thanks for your help in advance!

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 2 May 2016
Edited: Azzi Abdelmalek on 2 May 2016
This is not good, Use instead a cell array
matrix{1} = [1:10];
matrix{2} = [1:20]
  3 Comments
Jake
Jake on 2 May 2016
Thanks Walter! This helps. However, I forgot to mention earlier that the original matrix that I have is based on text.file. So, after running script as you can see below, I have tmp = {284781x1 cell}, which is actually 53 columns (i.e. variables) existing within this cell structure format for each row.
fid = fopen(filename,'r');
tmp = textscan(fid,'%s','Delimiter','\n');
Given a suggested solution you mentioned above, I have 100,000 rows (1X411 char) in each matrix which is remaining a char format.
How can I break each row of char format and convert into cell matrix as a result?? Thus, I want to have a cell matrix of [100,000 x 53] instead of a char matrix of [100,000 x 1]...
Please share your thoughts. Thanks for your help again!!!

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!