Performing operations on row elements in a matrix
So I’m creating some simple examples on trying to perform operations between rows in a matrix such as division. I have a matrix where:
my_mat = [2 4 6 8; 4 8 12 16]
which looks like so when printed.
my_mat =
2 4 6 8
4 8 12 16
and what I’m trying to do now is to divide the elements of the first row with the corresponding neighbouring ones which is the second row in this case since it’s only a 2×4 matrix. This means 2/4, 4/8, 6/12 and 8/16
Then perhaps printing out the result as the output
0.5
0.5
0.5
0.5
How do i perform row operations in a single matrix?
I’ve looked into bsxfun but apparently i can’t figure out the way to perform row operations with it.So I’m creating some simple examples on trying to perform operations between rows in a matrix such as division. I have a matrix where:
my_mat = [2 4 6 8; 4 8 12 16]
which looks like so when printed.
my_mat =
2 4 6 8
4 8 12 16
and what I’m trying to do now is to divide the elements of the first row with the corresponding neighbouring ones which is the second row in this case since it’s only a 2×4 matrix. This means 2/4, 4/8, 6/12 and 8/16
Then perhaps printing out the result as the output
0.5
0.5
0.5
0.5
How do i perform row operations in a single matrix?
I’ve looked into bsxfun but apparently i can’t figure out the way to perform row operations with it. So I’m creating some simple examples on trying to perform operations between rows in a matrix such as division. I have a matrix where:
my_mat = [2 4 6 8; 4 8 12 16]
which looks like so when printed.
my_mat =
2 4 6 8
4 8 12 16
and what I’m trying to do now is to divide the elements of the first row with the corresponding neighbouring ones which is the second row in this case since it’s only a 2×4 matrix. This means 2/4, 4/8, 6/12 and 8/16
Then perhaps printing out the result as the output
0.5
0.5
0.5
0.5
How do i perform row operations in a single matrix?
I’ve looked into bsxfun but apparently i can’t figure out the way to perform row operations with it. image processing, matlab, rows, matrix MATLAB Answers — New Questions