Combining multiple columns into one matrix in Matalb

In summary, to combine multiple columns into one matrix in Matlab, you can use the "horzcat" function. This function can also combine columns with different sizes, but the resulting matrix will have the size of the largest column and smaller columns will be padded with zeros. You can also specify the order of columns when combining them using the "horzcat" function. There is no limit to the number of columns that can be combined, but keep in mind that the resulting matrix may require more memory to store. In addition, it is possible to combine columns from different data types, but the resulting matrix will have the data type of the largest column.
  • #1
bashar_aden
1
0
Hi

I am a beginner in using Matlab software. I want to combine 300 columns into one matrix. The dimension of each column is 24x1. Meaning, the resultant matrix should have a dimension of 24x300. Anybody can help me in this?

Any help is much appreciated!

Thanks
 
Physics news on Phys.org
  • #2
try:

for i =1:300
Big_Matrix(:,i) = small_matrix;
end

if that isn't right, then replace (:,i) by (i,:), I always screw it up and have to redo it.
 

Related to Combining multiple columns into one matrix in Matalb

1. How do I combine multiple columns into one matrix in Matlab?

To combine multiple columns into one matrix in Matlab, you can use the horzcat function. This function takes in multiple matrices or vectors as inputs and concatenates them horizontally, creating a new matrix with all the columns combined.

2. Can I combine columns with different sizes into one matrix in Matlab?

Yes, you can combine columns with different sizes into one matrix in Matlab. However, the resulting matrix will have the size of the largest column. The smaller columns will be padded with zeros to match the size of the largest column.

3. How do I specify the order of columns when combining them into one matrix in Matlab?

You can specify the order of columns when combining them into one matrix in Matlab by using the horzcat function with the desired order of columns as inputs. For example, if you want to combine columns A, B, and C in that order, you can use horzcat(A, B, C).

4. Is there a limit to the number of columns I can combine into one matrix in Matlab?

No, there is no limit to the number of columns you can combine into one matrix in Matlab. However, keep in mind that the resulting matrix will have a larger size and may require more memory to store.

5. Can I combine columns from different data types into one matrix in Matlab?

Yes, you can combine columns from different data types into one matrix in Matlab. However, the resulting matrix will have the data type of the largest column. If the data types are incompatible, Matlab will convert them to the closest compatible data type.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
797
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
965
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Linear and Abstract Algebra
Replies
5
Views
929
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top