Matlab: Create Matrix from Single Column Data

  • Thread starter Thread starter rishabhdutta
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
To create a matrix from a single column of data in MATLAB, the 'reshape' function can be used if the total number of elements matches the desired matrix dimensions. If the dimensions differ, looping through the data may be necessary. Users are encouraged to familiarize themselves with the colon (:) operator for extracting parts of vectors and matrices. An example provided illustrates how to manipulate matrices using basic operations. Understanding these MATLAB functions is crucial for effective data manipulation.
rishabhdutta
Messages
4
Reaction score
0
I have a single column data of say length 1000. I want to make a matrix m * n using that data. m*n may need not be 1000, it can be less. looking for the script.
 
Physics news on Phys.org
If you're allowed to use built-in commands, you can use 'reshape':
http://www.mathworks.com/help/techdoc/ref/reshape.html

If you're not, you're going to have to do some looping:
http://www.mathworks.com/help/techdoc/matlab_prog/brqy1c1-1.html

We can't do your work for you, however.
 
Last edited by a moderator:
Thank you for the effort.

Had to use looping. reshape couldn't help me much as the no. of elements in the desired matrix have to be same as in the provided matrix form. for eg. I would like to get 4*3 matrix from the 15*1 matrix
 

Similar threads

Replies
8
Views
2K
Replies
0
Views
1K
Replies
3
Views
1K
Replies
10
Views
2K
Replies
7
Views
2K
Replies
2
Views
2K
Replies
8
Views
1K
Back
Top