A llittle challenge

4 views
Skip to first unread message

shakeel salamat

unread,
Sep 19, 2009, 8:39:58 AM9/19/09
to wirele...@googlegroups.com
Any one tell me the ingenious way of doing this thing without using for loop.
This coding is done in matlab.


Here h11,h12,h21,h22 are four linear arrays.

count=1;
for counter=1:2:length(h11est)*2
    H(counter,counter)=h11est(count);
    H(counter,counter+1)=h21est(count);
    H(counter+1,counter)=h12est(count);
    H(counter+1,counter+1)=h22est(count);
    count=count+1;
end

Ashwini Patankar

unread,
Sep 19, 2009, 9:19:15 AM9/19/09
to wirele...@googlegroups.com
count =1; counter =1;
while (counter <= length.....){
statements....
counter \ counter +2;
count = count +1;
--
Thanks and Regards,

Ashwini Shankar Patankar | +91 93202 43917
www.ashwinipatankar.com | www.wirelesscafe.wordpress.com

PS: Take out a print only when it is really necessary !

shakeel salamat

unread,
Sep 19, 2009, 10:06:59 AM9/19/09
to wirele...@googlegroups.com
OHh I mean without using any loop that is neither for nor while loop. 
anyways thanks for the try.

Ashwini Patankar

unread,
Sep 20, 2009, 11:37:59 PM9/20/09
to wirele...@googlegroups.com
hi,
Can you give any example matrix or array for this h11 etc. so that it will be more clear what exactly goin on , I think it si may be but possible.

Thanks and Regards,

Ashwini Shankar Patankar | +91 93202 43917
www.ashwinipatankar.com | www.wirelesscafe.wordpress.com

PS: Take out a print only when it is really necessary !


shakeel salamat

unread,
Sep 21, 2009, 5:44:42 AM9/21/09
to wirele...@googlegroups.com
h11=[a1 a2 a3 a4];
h12=[b1 b2 b3 b4];
h21=[c1 c2 c3 c4];
h22=[d1 d2 d3 d4];

These are four arrays with four elements each. I want this output.

a1  b1  0   0    0    0   0   0
c1  d1  0   0    0    0   0   0
0    0   a2  b2  0    0   0   0
0    0   c2  d2  0    0   0   0
0    0   0    0  a3  b3  0    0 
0    0   0    0  c3  d3  0    0
0    0   0    0  0    0   a4  b4
0    0   0    0  0    0   c4  d4

No need to worry about length of code. It should just be avoiding loops.

Ashwini Patankar

unread,
Sep 21, 2009, 6:07:02 AM9/21/09
to wirele...@googlegroups.com
With out loops there are two ways, 
1. do the assignments manually like 
   make a matrix h of 4x4 from h11, h22 etc. taking each as row and then take i=0,
   say we want C matrix
    C[i,i] = h[i,i];
    C[i+1, i] = h[i+1,i];
  and so on incrementing i at the right time, THis is one of the with out loop solution.

2. rearrange the h matrixs in more better way so as to use the various matrix manupulaiton commands like cat , diagonal etc.

But truely speaking none of this is as generalised as using the loop, coz then only you can get most general solution for any type of matrix. loops like while, for etc. are excelent for this purpose.

If any other solution came to you r mind then please share, I really want to know how to generate this matrix generally. Also the algorithm can be varied on the fact that how this h matrix is getting generated, may be modifiying the output we can direclty take them into one bigger matrix :)


Thanks and Regards,

Ashwini Shankar Patankar | +91 93202 43917
www.ashwinipatankar.com | www.wirelesscafe.wordpress.com

PS: Take out a print only when it is really necessary !
Sent from Mumbai, MH, India

shakeel salamat

unread,
Sep 21, 2009, 11:51:51 AM9/21/09
to wirele...@googlegroups.com
your first technique requires loop.
your second technique sounds good.
Reply all
Reply to author
Forward
0 new messages