Matlab - referencing a general element?

  • MATLAB
  • Thread starter dt19
  • Start date
  • #1
47
0

Main Question or Discussion Point

Hi,

Is there a way to associate each element with its row and column number without explicitly doing each one in turn? I have a matrix and I want to multiply it by a matrix whose elements are a function which takes as its input values the row and column number of the first matrix.
(I think essentially I'm trying to treat the matrix as a grid of coordinates).
What I'm trying to do is to say,
new_matrix(a,b) = old_matrix(a,b) * f(a,b)
where a and b are the row and column number.

My problem is I don't know how to tell matlab that I want a to be the row number and b to be the column number. My current idea is to create two matrices, one with all the column values equal and incrementing by 1, and the other the same but with row values equal, and treat these as x and y matrices, but this seems like a rather long-winded way of doing it. Can anyone help? (I'm new to matlab so it's probably something really obvious!)
 

Answers and Replies

Related Threads on Matlab - referencing a general element?

Replies
1
Views
6K
Replies
2
Views
2K
Replies
2
Views
11K
Replies
5
Views
2K
Replies
1
Views
20K
Replies
1
Views
4K
Replies
2
Views
3K
Replies
2
Views
3K
Replies
1
Views
7K
Replies
3
Views
649
Top