Re: Check content of an multi dimsenional array
- From: "Xiao " <viva_paradise@xxxxxxxxxxx>
- Date: Fri, 23 Jan 2009 14:33:02 +0000 (UTC)
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));
.
- Follow-Ups:
- Re: Check content of an multi dimsenional array
- From: Walter Roberson
- Re: Check content of an multi dimsenional array
- References:
- Check content of an multi dimsenional array
- From: Xiao
- Re: Check content of an multi dimsenional array
- From: Pekka Kumpulainen
- Check content of an multi dimsenional array
- Prev by Date: Re: Check content of an multi dimsenional array
- Next by Date: Re: memmapfile
- Previous by thread: Re: Check content of an multi dimsenional array
- Next by thread: Re: Check content of an multi dimsenional array
- Index(es):
Relevant Pages
|