Subtracting Values in a cell with respect to results from nchoosek?
Show older comments
Suppose I hav an array a which are basically indices of some values
a = [1 2 3]
b = nchoosek(a,2)
c= size(b)
d = cell(c)
b =
1 2
1 3
2 3
c =
3 2
d =
[] []
[] []
[] []
Now in this cell d, I want to put some values. I have a another cell say newCell (1xn) (here n is always same length as a) which contains double
newCell =
[12737x1 double] [47712x1 double] [6514x1 double]
so i want to have
d = [12737x1 double] [47712x1 double]
[12737x1 double] [6514x1 double]
[47712x1 double] [6514x1 double]
What I want to do in the end is sbutract each values from newCell but with respect to the nchoosek results. Because [12737x1 double] is values for 1
[47712x1 double] is values for 2
[6514x1 double] is values for 3
I am aware we can subtract the values only if the length is same. SO that is where I am stuck. I don no how to go further with this. So I will have to have a if condition for checking if length is same, If it is then it should subtract the values and answer should be zero. If it not same then it should not subtract the values. Say For example:
newCell =
[12737x1 double] [12737x1 double] [6514x1 double]
now d should be
d = [12737x1 double] [12737x1 double]
[12737x1 double] [6514x1 double]
[12737x1 double] [6514x1 double]
It should now check if length is same, then subtract 1st row and store [1 2]in an array keepin in mind that 1 2 are the indices from a. This I want to do for over 150k files. Is there a solution to this. I just have an idea but do not no how to go further with is. Thanks in advance.
3 Comments
It's not clear (to me). I can see that you want to start this by doing
d=newCell(b);
But now, I don't understand the subtractions you intend to do. What do you mean by "check if length is same". What 2 things are you trying to subtract?
Matt J
on 18 Oct 2012
I assume you mean d instead of newCell. You should do it as you've written it.
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion 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!