Matlab- summing of vectors in a matrix

  • Context: MATLAB 
  • Thread starter Thread starter jaobyccdee
  • Start date Start date
  • Tags Tags
    Matlab Matrix Vectors
Click For Summary
SUMMARY

The discussion focuses on summing specific columns of an 8000x600 matrix in MATLAB. The user aims to sum columns indexed by the formula (4*i+1) for i ranging from 0 to 149. The solution provided utilizes MATLAB's indexing capabilities, specifically creating an index vector 'i' and applying it to the matrix 'V' to compute the sum using the command 'sum(V(:,i)')'. This method efficiently aggregates the desired columns in a single operation.

PREREQUISITES
  • Familiarity with MATLAB syntax and matrix operations
  • Understanding of matrix indexing in MATLAB
  • Basic knowledge of vector arithmetic
  • Experience with MATLAB's built-in functions like 'sum'
NEXT STEPS
  • Explore advanced MATLAB indexing techniques
  • Learn about vectorization in MATLAB for performance optimization
  • Investigate MATLAB's matrix manipulation functions
  • Study the implications of large matrix operations on memory usage in MATLAB
USEFUL FOR

Mathematics students, data analysts, and engineers who utilize MATLAB for matrix computations and require efficient methods for summing specific columns in large datasets.

jaobyccdee
Messages
33
Reaction score
0
I have a 8000x600 Matrix called V. How can i add the colume 1,5,9,13,17... (all colume of (4*i+1) for i from 0 to 149) of the vector?
 
Physics news on Phys.org
Say that the matrix is called V

Code:
i = [0:149]*4 +1;
sum(V(:,i)');
 

Similar threads

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