Is there such a matrix operation

  • Context: Undergrad 
  • Thread starter Thread starter Wolfgang2b
  • Start date Start date
  • Tags Tags
    Matrix
Click For Summary
SUMMARY

The discussion centers on performing a matrix operation with two row vectors, A and B, where A = [1 0 0 1 0 1] and B = [a b c]. The goal is to create a new vector C = [a 0 0 b 0 c] by replacing the 1's in A with the corresponding elements from B while leaving the 0's intact. Participants emphasize the need for a method that avoids element-wise access, suggesting a desire for a more efficient operation than traditional indexing. The conversation also highlights the importance of using proper mathematical notation, such as LaTeX, for clarity.

PREREQUISITES
  • Understanding of matrix operations and vector manipulation
  • Familiarity with MATLAB for matrix storage and operations
  • Knowledge of LaTeX for mathematical notation
  • Basic concepts of linear algebra, specifically row and column vectors
NEXT STEPS
  • Research MATLAB matrix manipulation functions, particularly for vector indexing
  • Explore advanced matrix operations in linear algebra, such as Kronecker products
  • Learn about element-wise operations in MATLAB and how to optimize them
  • Study the use of LaTeX for formatting mathematical expressions in discussions
USEFUL FOR

This discussion is beneficial for mathematicians, data scientists, and MATLAB users who are looking to optimize matrix operations and improve their understanding of vector manipulation techniques.

Wolfgang2b
Messages
31
Reaction score
0
Say I have two matrices of the form

A = [1 0 0 1 0 1] (1 x 6 row vector)

and

B = [ a b c] (1 x 3 row vector). The number of elements in B = number of 1s in A.

Is there any matrix operation that could be done on A and B that would give me C = [a 0 0 b 0 c]? That is the 1's of A should be replaced with the values in B and zeros left as it is.

I am looking for operations that would not access the individual elements separately (i.e. I am not looking for things like if A(1)==1, C(1)=A(1)*b(1) etc... or inserting zeros.) I am looking for some operation like A*B that would give this result.

Sorry about the cryptic title. I can't really describe it without examples.
 
Last edited:
Physics news on Phys.org
Wolfgang2b said:
Say I have two matrices of the form

A = [1 0 0 1 0 1]


Either this is a \,1\times 6\, matrix, which is the same as a six-coordinate row vector, or you meant something else

that I, at least, cannot imagine what it is.

and

B = [ a b c]. The number of elements in B = number of 1s in A.


The same as above. Do you know what a matrix is? You should also know we have LaTeX in this site for us all to

properly write mathematics. This would be a huge improvement in this kind of question.

DonAntonio


Is there any matrix operation that could be done on A and B that would give me C = [a 0 0 b 0 c]? That is the 1's of A should be replaced with the values in B and zeros left as it is.

I am looking for operations that would not access the individual elements separately (i.e. I am not looking for things like if A(1)==1, C(1)=A(1)*b(1) etc... or inserting zeros.) I am looking for some operation like A*B that would give this result.

Sorry about the cryptic title. I can't really describe it without examples.
 
DonAntonio said:
Either this is a \,1\times 6\, matrix, which is the same as a six-coordinate row vector, or you meant something else

that I, at least, cannot imagine what it is.

Yes, it is a 1 x 6 row vector or you can take the transpose and consider it a 6 x 1 column vector. Doesn't really matter. Same for the other matrix.
DonAntonio said:
Do you know what a matrix is? You should also know we have LaTeX in this site for us all to

properly write mathematics. This would be a huge improvement in this kind of question.

DonAntonio
I know there was a matrix with Keanu Reeves in it. Like that one actually. I also have done few problems with the matrices in math. I don't know why this is relevant here. Can't I call row vectors as matrices? I store them as matrices in Matlab and would like to do matrix operations.

I also don't see the need to write this question in LaTeX as it does not contain any complex equations that would otherwise be unintelligible. However I would do that in future questions. For now, I will update the OP.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
4K
Replies
3
Views
2K
  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K