From: Gumah on 1 May 2010 22:11 Hi all say we have: A=[ 0 0 0 1 1 1 0 0 0] how to use the operator ~ to convert only the third element from 0 into 1 so we will have: A=[ 0 0 1 1 1 1 0 0 0]
From: Gumah on 1 May 2010 23:05 On May 2, 10:11 am, Gumah <alrjele2...(a)gmail.com> wrote: > Hi all > say we have: > A=[ 0 0 0 1 1 1 0 0 0] > how to use the operator ~ to convert only the third element from 0 > into 1 so we will have: > A=[ 0 0 1 1 1 1 0 0 0] Sorry..The question should be like that: how can I convert a specific element in array that represent a binary image from black into white A=[ 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0] This array reperesent an image of line.. say I wanna make this line longer.. thus I want to convert the second element in the third column from 0 into 1 so A will be look like: A=[ 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0] any body knows how to do that?
From: Matt Fig on 1 May 2010 23:59 Why not just simply: A(2,3) = 1;
From: Walter Roberson on 2 May 2010 00:11 Gumah wrote: > On May 2, 10:11 am, Gumah <alrjele2...(a)gmail.com> wrote: >> Hi all >> say we have: >> A=[ 0 0 0 1 1 1 0 0 0] >> how to use the operator ~ to convert only the third element from 0 >> into 1 so we will have: >> A=[ 0 0 1 1 1 1 0 0 0] > > Sorry..The question should be like that: how can I convert a specific > element in array that represent a binary image from black into white > A=[ 0 0 0 0 0 0 0 0 0 0 > 0 0 0 1 1 1 1 0 0 0 > 0 0 0 0 0 0 0 0 0 0] > This array reperesent an image of line.. say I wanna make this line > longer.. thus I want to convert the second element in the third column > from 0 into 1 so A will be look like: > A=[ 0 0 0 0 0 0 0 0 0 0 > 0 0 1 1 1 1 1 0 0 0 > 0 0 0 0 0 0 0 0 0 0] > any body knows how to do that? If necessary, you could use code like this: NOT = @(V) true(1) - V&V; Rows = [2]; Cols = [3]; MatIdx = sub2idx(size(A), Rows, Cols); NewAVector = vertcat(A(1:MatIdx), NOT(A(MatIdx)), A(MatIdx+1:end)); NewA = reshape(NewAVector, size(A)); PS: I don't claim the above code is _efficient_, but as you research what it does, you should be able to figure out the very simple answer to your question.
|
Pages: 1 Prev: diesel generator model -MATLAB Next: error using C function in Matlab |