From: us on
"roya olyazadeh" <roya2543(a)gmail.com> wrote in message <hss0tk$af1$1(a)fred.mathworks.com>...
> If Q =
> 2 3 4
> 4 5 6
> 7 8 9
> >If i =2
> Q =
>
> 2 0 3 4
> 0 0 0 0
> 4 0 5 6
> 7 0 8 9
>
> Now what is the solution ?

depends on the rule you (might) have...
otherwise,
one of the solutions

t=true;
f=false;
sm=[
2 3 4
4 5 6
7 8 9
];
btmpl=[
t f t t
f f f f
t f t t
t f t t
];
bm=zeros(size(btmpl));
bm(btmpl)=sm;

us
From: Nathan on
On May 17, 11:12 am, "roya olyazadeh" <roya2...(a)gmail.com> wrote:
> If Q =
>                  2    3   4  
>                  4    5   6
>                  7   8    9>If i =2
>
> Q =
>
>            2  0  3    4  
>            0  0  0    0
>            4  0  5    6
>            7  0  8    9
>
>       Now what is the solution ?

A generalized solution for a given row i and column j:

Q = [2 3 4;4 5 6;7 8 9];
Q1 = zeros(size(Q)+1)
i=2; j=3;
tmp = 1:length(Q1);
tmp1 = 1:length(Q1);
tmp(i)=[];tmp1(j)=[];
Q1(tmp,tmp1) = Q
%%%%%%%%%%%%%%%%%%%%%
Q1 =
2 3 0 4
0 0 0 0
4 5 0 6
7 8 0 9

-Nathan
From: roya olyazadeh on
Nathan <ngreco32(a)gmail.com> wrote in message <19809f1a-3f22-4c1d-aec4-959dbac0153f(a)42g2000prb.googlegroups.com>...
> On May 17, 11:12 am, "roya olyazadeh" <roya2...(a)gmail.com> wrote:
> > If Q =
> >                  2    3   4  
> >                  4    5   6
> >                  7   8    9>If i =2
> >
> > Q =
> >
> >            2  0  3    4  
> >            0  0  0    0
> >            4  0  5    6
> >            7  0  8    9
> >
> >       Now what is the solution ?
>
> A generalized solution for a given row i and column j:
>
> Q = [2 3 4;4 5 6;7 8 9];
> Q1 = zeros(size(Q)+1)
> i=2; j=3;
> tmp = 1:length(Q1);
> tmp1 = 1:length(Q1);
> tmp(i)=[];tmp1(j)=[];
> Q1(tmp,tmp1) = Q
> %%%%%%%%%%%%%%%%%%%%%
> Q1 =
> 2 3 0 4
> 0 0 0 0
> 4 5 0 6
> 7 8 0 9
>
> -Nathan


I tried to use this .

for i = 1 : length(stn) % number of station
if fix1(i)==1 % If station is fixed

Q1 = zeros(size(Qx)+1);

tmp = 1:length(Q1);
tmp1 = 1:length(Q1);
tmp(i)=[];tmp1(i)=[];
Q1(tmp,tmp1) = Qx;
end
end

Any time fix1(i) matrix = 1 It should do these operations.
but it gave me just last result .

In this example i = 1 , 3,4

So Q1 must be something like this :

0 0 0 0 0 0
0 2 3 0 0 4
0 0 0 0 0 0
0 0 0 0 0 0
0 4 5 0 0 6
0 7 8 0 0 9
From: roya olyazadeh on
My mistake... Q1 must be like this :
>
> In this example i = 1 , 3,4
>
> So Q1 must be something like this :
>
> 0 0 0 0 0 0
> 0 2 0 0 3 4
> 0 0 0 0 0 0
> 0 0 0 0 0 0
> 0 4 0 0 5 6
> 0 7 0 0 8 9
From: Jos (10584) on
"roya olyazadeh" <roya2543(a)gmail.com> wrote in message <hstkfj$sbc$1(a)fred.mathworks.com>...
> My mistake... Q1 must be like this :
> >
> > In this example i = 1 , 3,4
> >
> > So Q1 must be something like this :
> >
> > 0 0 0 0 0 0
> > 0 2 0 0 3 4
> > 0 0 0 0 0 0
> > 0 0 0 0 0 0
> > 0 4 0 0 5 6
> > 0 7 0 0 8 9

Easy enough with the right tools:

% data
Q = [2 3 4 ; 4 5 6 ; 7 8 9] ;
ix = [1 2 2] ; % your ix was defined with reference to the outcome
% engine
Q1 = insertrows(Q,0,ix-1) % note the -1
Q1 = insertrows(Q1.',0,ix-1).' % note the transpose twice

INSERTROWS can be found here:
http://www.mathworks.com/matlabcentral/fileexchange/9984

hth
Jos