Normalize matrix elements resulting in sum of elements of one.
Show older comments
Hi,
For part of my matlab code I have to normalize a space-variant matrix K:
K[u][v](x,y)
so that the sum (u and v) of all locations in this matrix after normalization is 1:
∑∑K[u][v](x,y) = 1
However, I'm not sure where to begin with this. Could someone help me with the steps I should take?
Thanks!
8 Comments
Sammit Jain
on 28 Nov 2017
Hi, can you post an example of what you're looking to do? Is it orthogonalization that you're trying to attempt?
Ihiertje
on 28 Nov 2017
John D'Errico
on 28 Nov 2017
LEARN to think in MATLAB terms, at least to express yourself that way when you are talking MATLAB.
This means little in terms of a question about MATLAB:
K[u][v](x,y)
Does it mean that you have a 4 dimensional matrix K? Or does it mean that at any location in space, thus the (x,y) plane, the matrix elements must sum to 1?
If the latter is the case, then are the elements of a square matrix K, thus K(u,v), each functions of x and y? So is K a symbolic array? Or is K itself essentially a function of the location in the coordinate plane thus you have a function that takes in (x,y) coordinates, and returns a matrix K?
Unless you explain what you mean, then no answer is really possible.
Jan
on 28 Nov 2017
What exactly is "a space-variant matrix K:K[u][v](x,y)"? Remember, that the members of this forum understand Matlab syntax, but the vast majority of them will not work in your field of science. But as long as Matlab understand Matlab only also, it is worth to reformulate the question in a a way, which can be understood by Matlab. Please edit your question and append more details.
Jan
on 28 Nov 2017
@Ihiertje: Almost clear now. So is your input is e.g.
X = rand(512, 512)
or
X = randi([1, 512], 512, 512)
? Now explain, what should be normalized now: The sum over the columns, over the rows or over all elements?
Ihiertje
on 28 Nov 2017
Answers (2)
Jan
on 28 Nov 2017
Perhaps you want:
A = rand(5, 5); % Test data
B = A / sum(A(:))
If you want something else, please explain which sum should be 1.
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!