"what ever" <vasco_taveira@hotmail.com> wrote in message <hnpp5b$e2l$1@fred.mathworks.com>...
> HELLO!! :)
> need help people!!
>
> imagine: M=[1,2,3 ;
> 4,5,6 ;
> 7,8,9]
>
> now i say: x=2 (needs to be to any x; in this case x between 1 and 3!)
>
> the new matrix should be:
>
> NEW_M=[ 1,0,2,3 ;
> 0,0,0,0 ;
> 4,0,5,6 ;
> 7,0,8,9 ]
>
> I tried a lot, but i have problems putting the values: 2,3,4 and 7(for this especific case). It appears zero!
>
>
> My code is:
>
> for hh=1:aux_invB
> for j=1:aux_invB
> hh2=hh;
> j2=j;
>
> if j<REFBUS && hh<REFBUS
>
> t_aux_invB2(hh2,j2)=MB2(hh,j);
>
> end
>
> if hh>REFBUS1 && j>REFBUS1
>
> t_aux_invB2(hh2+1,j2+1)=MB2(hh,j);
>
> end
> end
> end
>
> I deleted the part of the code when 'j' and 'hh' are ==REFBUS because it was bad!! :(
> This code needs to be for a generalized matrix, the size of the matrix should not matter!!
>
> Can someone help me pleaseee??
Assuming a square M matrix:
x = 2;
[m n] = size(M);
y = [1:(x1) (x+1):(n+1)];
NEW_M = zeros(m+1,n+1);
NEW_M(y,y) = M;
James Tursa
