Re: Check content of an multi dimsenional array



Hi all

I am given a cell that looks like the one shown below:

Example:

network = [0 11 12 0 0 0 0;
0 0 0 11 0 11 0;
0 0 0 12 0 0 12;
0 0 0 0 12 0 0;
0 0 0 0 0 12 12],

if we take 1st column, there is no value (All zeros) in it.

Now the second column, there is a value(11) and the position of this value is at network (1,2). I need to store this position in an array

For the fourth column, there is 2 values (11&12), i need to store their positions [network(2,4) & network (3,4) ] in the array.

How do i go about doing it?

Regards.


"Pekka Kumpulainen" <pekka.nospam.kumpulainen@xxxxxxxxxxxxx> wrote in message <glbvhj$3ur$1@xxxxxxxxxxxxxxxxxx>...
"Xiao " <viva_paradise@xxxxxxxxxxx> wrote in message <glbteb$3f6$1@xxxxxxxxxxxxxxxxxx>...
Hi all,

i have a multi-dimensional array as follows:

network = cat(3, [0 11 12 0 0 0 0;
0 0 0 11 0 11 0;
0 0 0 12 0 0 12;
0 0 0 0 12 0 0;
0 0 0 0 0 12 12], [0 21 22 0 0 0 0;
0 0 0 21 0 21 0;
0 0 0 22 0 0 22;
0 0 0 0 22 0 0;
0 0 0 0 0 22 22]);

i need to check each location to see if there is any content in it. If there is, i need to store the address in an array. How do i go about doing it?

eg.

for dep = 1:2
for col = 1:5
for row = 1:5

% If there is a content, store the address in array.

end;
end;
end;

Do help me in this.
Thank you.

Do you mean content is anything larger than 0?
doc relop
doc find
doc ind2sub
after reading those, you can do (if I understood right what you want)
[I,J,K] = ind2sub(size(network),find(network>0));


.



Relevant Pages

  • Re: newbie: force paste as text?
    ... in an array, so I don't have the luxury of copying a cell at a time. ... Excel drops leading zeros when that is done unless the cell ... | Dim rets As String ...
    (microsoft.public.excel.programming)
  • Re: Finding the nearest match without reusing results
    ... comparing an array with a value generates an array of Trues and ... Any diff with wrong State or with used Store is implicitly zeroed out. ... Each must be larger than the absolute value of the maximum Sales ... go.....it just needs to return the closest match. ...
    (microsoft.public.excel.programming)
  • Re: read keyboard input and storing in an array?
    ... > I'm trying to store user input in an array, ... You have the beginnings of that logic already since your prompt tells the ... 201st value since the array only has room for 200 values. ... This will force you to store the int values as Integer ('Integer' ...
    (comp.lang.java.help)
  • Re: Storing a column of input data
    ... You can store 32K characters in a cell. ... This stores the array in a defined name, ...
    (microsoft.public.excel.programming)
  • Re: Challenge: reading ascii data
    ... to store all the data before producing any output. ... would be bad practice in terms of memory consumption to use a standard ... So I use hashes to create a two-level "sparse array", ... Well the original problem definition was: ...
    (comp.lang.fortran)