I have a question as follow:
for example:
network = [] [1;0] [] ;
[] [] [0;1] ;
[] [] [1;0] ;
[] [] [] ;
[] [] [] ],
First, i need to check through the columns to see if there is more than one item in it. Based on the network, col 3 has more than one item. After which, i need to store the positions of the 2 items.
that means to say,
When more than 1 item in a column
store those positions [network (2,3) & network (3,3)] in an ARRAY.
I am using, [I, J] = ind2sub (size(network), CONDITION)
but what is the condition i need to set, so that it can store the 2 positions (network(2,3) & network(3,3))?
Thank you.
your example is not quite clear (why is network(1,2) not used?)...
one of the solutions
% the data
c={
[],[1,2],[]
[],[],[3,4]
};
% the engine
[ir,ic]=find(~cellfun(@isempty,c));
% the result
disp([ir,ic]);
%{
% row / col
1 2
2 3
%}
us
only when the number of items in a column exceed 1, then i store the position of those involved items. hence, network (1,2) is not used. In the example, only column 3 has more than 1 item, hence i need to store those address [network (2,3) & network (3,3)].
I hope this is clear enough..
Do help me out.
Thank you.
"us " <u...@neurol.unizh.ch> wrote in message <glm9n6$q2j$1...@fred.mathworks.com>...
I tried using the solution provided. However, it doesnt fulfill the requirement that I have mentioned earlier.
What I need is (When Number of items in each column> 1, store those address that belong to the column)
I tried using ind2sub also. But i cant get it right..
What i did is as follows:
[I, J] = ind2sub(size (network), find(Number of items in each col > 1)),
Can anyone have a solution for this?
Waiting for your reply.
Thank you.
"Xiao " <viva_p...@hotmail.com> wrote in message <glmasl$dd0$1...@fred.mathworks.com>...
one of the solutions
% the data
c={
[],[],[],[]
[],[1,2],[],[-1,-2]
[],[],[3,4],[-3,-4]
[],[],[5,6],[]
};
% the engine
ix=sum(~cellfun(@isempty,c))<=1;
c(:,ix)={[]};
[rx,cx]=find(~cellfun(@isempty,c));
% the result
disp([rx,cx]);
%{
% row#/col#
3 3
4 3
2 4
3 4
%}
us
Thank you.
Is it possible to perform an addition of the content (content of row 3 col 3 + content of row 4 col 3) and display the results as well ?
Where should i edit the program?
Waiting for your reply.
Thank you for your help.
"us " <u...@neurol.unizh.ch> wrote in message <glpuca$drc$1...@fred.mathworks.com>...
the LAST one of the solutions...
% the data
c={
[],[],[],[]
[],[1,2],[],[-1,-2]
[],[],[3,4],[-3,-4]
[],[],[5,6],[]
};
% the engine
ix=sum(~cellfun(@isempty,c))<=1;
c(:,ix)={[]};
[rx,cx]=find(~cellfun(@isempty,c));
cu=unique(cx);
r=arrayfun(@(x) sum([c{:,x}]),cu);
% the result
disp(r);
%{
18 % col# 3
-10 % col# 4
%}
us