square root of sum of squares on portions of cell arrays - Matlab Noob
Show older comments
I have a cell array, out5, with a single column of 2x1 vectors. I would like to take the square root of the sum of the squares of the two values in each vector for each of these vectors. I was looking at doing some code similar to this:
cellfun(@hypot,out5)
where,
out5 =
[0;0]
[0;-162]
[-54;72]
...
I would desire the output to be:
out6 = [sqrt(0^2 + 0^2) ; sqrt(0^2 + (-162)^2) ; sqrt((-54)^2 + 72^2) ; ... ]
I would also like the values to be either positive or negative depending on the first values in the vectors of out5. so for instance, the third vector in the cell array out5 [-54;72] the value output would be a negative since the first value is negative. In this example the final result would be:
[0 ; 162 ; -90]
3 Comments
Siddharth Pande
on 28 Mar 2013
first of all my friend square of any negative number will always be positive so you will always get the positive value of the defined negative value try defining it in terms of positive values (i.e positive ranges).
Mark
on 28 Mar 2013
Siddharth Pande
on 28 Mar 2013
what is your cell an image for example if you are using a image in grey scale the piccture image quality is defined on 100 for white and 0 for black what i mean to say the darkest of the darkest image will also be a positve one so you define your image in positive range
Accepted Answer
More Answers (0)
Categories
Find more on Image Data 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!