Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Please help~ Matrix elements excess ,compare and list it index

Subject: Please help~ Matrix elements excess ,compare and list it index

From: VIC

Date: 30 Nov, 2010 17:17:08

Message: 1 of 2

I have a question here, i have a random generate 10 by 10 matrix, and i'd found out all the maximum values for each row.By using,

z=randint(10,10,100);
t=max(z,[],2) ;

and the results came out like this:
z=
     0 77 78 55 24 2 98 87 52 7
     4 0 42 35 11 21 43 5 74 31
    47 0 20 68 22 63 83 28 0 67
    42 63 19 53 85 50 3 83 22 23
    68 23 67 99 7 6 42 76 28 70
    94 46 72 11 46 11 93 34 90 79
    55 39 75 62 86 82 16 7 97 91
    84 84 19 27 18 85 59 30 40 90
    71 11 15 74 24 79 7 30 2 71
    76 85 82 65 11 2 50 83 27 2
t=
    98
    74
    83
    85
    99
    94
    97
    90
    79
    85

now,for the z matrix, lets say row represents <user> (u1,u2...u10) and column represents <subcarrier> (s1,s2....s10). We select the subcarrier with the maximum value and assign it to that particular user, then proceed to next row.
Example, for row 1 (u1) the best subcarrier value is 98 which is s7(subcarrier 7)

and now,i need to use <for loop> to check and list out the subcarrier. So that the result will come out like s(1,7)=1 which means subcarrier 7 is assigns to user 1
s(1,7)=k, where k represents user or row.

z=randint(10,10,100);
t=max(z,[],2) ;
for i=1:10 %no. of subcarrier
temp=0;
for j=1:10 %no. of users
if temp<r[i,j];
temp=r[i,j];

I have some syntax for the code above, such as r[i,j],what should i change it to? and is the code flow correct?
please help~

thank you

Subject: Please help~ Matrix elements excess ,compare and list it index

From: Sean de

Date: 30 Nov, 2010 21:30:23

Message: 2 of 2

"VIC " <vicnsc@yahoo.com> wrote in message <id3bik$quo$1@fred.mathworks.com>...
> I have a question here, i have a random generate 10 by 10 matrix, and i'd found out all the maximum values for each row.By using,
>
> z=randint(10,10,100);
> t=max(z,[],2) ;
>
> and the results came out like this:
> z=
> 0 77 78 55 24 2 98 87 52 7
> 4 0 42 35 11 21 43 5 74 31
> 47 0 20 68 22 63 83 28 0 67
> 42 63 19 53 85 50 3 83 22 23
> 68 23 67 99 7 6 42 76 28 70
> 94 46 72 11 46 11 93 34 90 79
> 55 39 75 62 86 82 16 7 97 91
> 84 84 19 27 18 85 59 30 40 90
> 71 11 15 74 24 79 7 30 2 71
> 76 85 82 65 11 2 50 83 27 2
> t=
> 98
> 74
> 83
> 85
> 99
> 94
> 97
> 90
> 79
> 85
>
> now,for the z matrix, lets say row represents <user> (u1,u2...u10) and column represents <subcarrier> (s1,s2....s10). We select the subcarrier with the maximum value and assign it to that particular user, then proceed to next row.
> Example, for row 1 (u1) the best subcarrier value is 98 which is s7(subcarrier 7)
>
> and now,i need to use <for loop> to check and list out the subcarrier. So that the result will come out like s(1,7)=1 which means subcarrier 7 is assigns to user 1
> s(1,7)=k, where k represents user or row.
>
> z=randint(10,10,100);
> t=max(z,[],2) ;
> for i=1:10 %no. of subcarrier
> temp=0;
> for j=1:10 %no. of users
> if temp<r[i,j];
> temp=r[i,j];
>
> I have some syntax for the code above, such as r[i,j],what should i change it to? and is the code flow correct?
> please help~
>
> thank you

Perhaps you should look at the second output argument to MAX.

If that is not what you want, please show a sample of what you want the temp to be at completion.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us