|
TideMan <mulgor@gmail.com> wrote in message <f595ceca-7060-4fe1-8b42-c30f6705ef43@g1g2000pro.googlegroups.com>...
> On Apr 30, 12:31 am, "Kenan " <kenan...@hotmail.com> wrote:
> > Hello everyone!
> >
> > I have a matrix consisting of random numbers at 163x6 size, and i want matlab to display the arrays whose first element would match to a given input element. For example if i type "2", it would list all the arrays which starts with "2". Like an elimination of arrays from the matrix.
> >
> > Is it possible to do it? I havent got much experience with Matlab, so i would appreciate it if anyone could help me.
> >
> > Thanks in advance,
> > Kenan
>
> Don't you mean that you want Matlab to display the elements whose
> first digit matches a given digit?
> Array is the generic word for a matrix, which is the special case of a
> 2-D array.
> Within an array there are many elements, and each element consists of
> 1 or more digits.
>
> If you want a sensible answer, you need to ask a sensible question.
> Asking for the specific array of a matrix is like asking for the
> specific animal of a dog. It's nonsense.
>
> Apart from all that, to paraphrase Urs, where have you personally
> gotten to in this homework?
Hello Tideman, and Us. I'm sorry for my language mistake. Actually i meant "row" while saying "array" :) You're right, it's very nonsense.
After having posted that message, somehow i could manage to do it. Here is the matrix and the code i wrote :
A=[5 15 20 32 34 47;
3 14 16 23 27 43;
6 22 26 31 38 44;
7 11 16 18 25 26;
2 5 14 30 31 39;
2 14 24 25 30 36;
4 8 14 24 27 36;
3 17 36 41 46 47;
4 15 16 18 27 41;
5 11 24 29 41 45;
22 26 37 38 39 49;
13 22 33 38 39 40;
11 18 30 40 41 43;
3 4 19 26 27 37;
14 28 32 38 41 45;
18 28 29 32 43 44;
2 16 20 22 25 27;
11 15 21 33 37 38;
2 12 13 25 30 39;
19 32 33 41 46 49;
1 2 18 19 23 45;
14 17 28 33 35 49;
1 2 4 12 35 48;
3 5 10 22 23 31;
5 11 17 36 38 41;
1 8 16 28 39 40;
15 20 23 30 39 47;
1 6 10 35 43 49;
8 13 21 28 34 38;
14 21 27 35 42 46;
11 18 36 38 44 48;
15 16 21 28 38 49;
8 13 23 25 38 40;
6 9 10 13 38 41;
2 9 11 13 27 49;
7 21 22 30 33 39;
5 11 13 24 38 47;
10 15 17 28 32 37;
8 16 20 28 36 45;
12 27 34 39 47 49;
8 16 26 28 34 47;
5 20 27 29 32 46;
7 13 14 16 17 21;
4 7 10 21 37 49;
7 27 30 33 38 46;
22 25 26 32 34 45;
14 20 28 38 41 48;
3 15 32 36 38 45;
17 21 22 24 30 47;
15 21 35 37 43 49;
1 13 16 19 33 35;
1 10 35 37 40 47;
1 17 31 32 41 43;
5 13 15 27 31 32;
12 19 35 41 46 47;
10 12 21 37 43 49;
8 14 21 37 39 41;
1 21 24 29 30 32;
1 21 26 32 33 48;
13 20 25 28 31 35;
11 14 20 27 37 38;
5 9 12 16 26 37;
7 14 19 34 41 42;
3 8 11 30 40 44;
2 7 27 41 42 45;
19 23 28 30 39 45;
10 18 27 35 38 49;
11 16 27 35 38 49;
3 8 15 35 40 49;
12 16 23 36 43 49;
2 7 16 24 25 36;
6 8 9 20 25 34;
1 4 15 33 39 42;
2 8 14 17 20 38;
1 20 22 35 39 47;
4 13 20 34 44 48;
6 10 18 28 29 30;
5 9 20 28 35 40;
13 16 28 29 39 46;
8 15 17 35 36 44;
9 11 12 13 37 47;
2 7 16 17 27 29;
1 4 17 20 23 43;
6 16 26 44 46 48;
11 15 33 40 45 48;
9 14 16 22 27 48;
20 22 24 29 34 41;
2 3 13 19 22 37;
5 24 41 43 45 47;
2 10 35 36 38 41;
3 4 5 10 16 20;
6 21 29 38 40 47;
5 17 18 39 42 46;
20 23 37 39 41 42;
7 29 36 38 41 42;
23 27 28 30 35 39;
19 23 25 40 41 44;
3 12 22 23 25 29;
8 13 20 32 37 42;
5 10 14 15 25 40;
9 12 19 22 24 32;
5 10 20 27 31 40;
17 19 30 43 45 48;
4 20 22 35 38 48;
7 11 15 17 21 26;
8 11 24 36 43 44;
5 8 11 25 34 48;
8 19 20 27 32 33;
4 5 14 32 35 46;
1 17 25 26 28 46;
1 3 7 39 46 49;
7 9 16 22 40 46;
14 20 21 23 28 44;
20 22 24 34 41 49;
14 32 33 34 35 47;
1 13 15 28 41 42;
11 15 19 24 28 39;
3 5 7 19 38 41;
12 13 30 31 41 48;
7 10 19 25 32 34;
18 25 29 34 38 42;
2 19 27 28 33 48;
3 9 26 42 46 48;
9 29 32 33 43 49;
1 9 10 23 30 48;
8 9 10 24 32 33;
1 9 17 23 43 47;
5 9 11 31 35 37;
2 5 6 32 44 49;
14 15 26 32 45 46;
6 18 26 33 34 41;
7 14 15 26 37 48;
2 10 13 26 33 47;
4 9 12 14 38 43;
27 29 35 39 42 45;
12 39 40 41 42 45;
17 25 29 31 33 46;
24 26 27 38 40 48;
6 8 17 32 36 46;
17 27 30 38 40 44;
6 7 12 17 20 47;
4 10 16 18 19 35;
8 12 13 21 25 47;
19 27 29 32 36 48;
7 12 17 20 28 38;
3 9 12 15 39 44;
2 18 20 23 26 44;
4 28 31 39 41 42;
2 6 7 14 39 46;
6 12 24 32 33 44;
3 7 28 32 46 47;
10 16 25 27 29 49;
5 19 24 26 29 40;
6 9 13 17 18 30;
6 14 17 21 22 46;
7 15 16 21 22 26;
19 20 26 28 31 46;
9 11 14 31 40 45;
1 6 14 27 39 49;
13 21 26 27 33 47;
8 12 15 17 27 31;
22 23 24 25 40 47;
2 7 18 22 36 37];
B=A(:,1);
a=input('Write the first number: ');
C=find(B==a);
K=size(C,1);
L=size(A,2);
Z=zeros(K,L);
for m=1:K
n=1:L;
Z(m,n)=A([C(m)],:)
end
Thus i could get the "rows" in the matrix A, which begins with the element "a".
But if you have a more convenient method, you're welcome to share it.
Thank you again.
Kenan
|