If you want the "location" you can use the linear index of that pixel:
p = sub2ind( size(a), 2, 1 );
new(p) = 1;
Question
I have the following matrix:
a =
1 4
6 4
After that, I created a zero matrix new
of the same size of a
:
new =
0 0
0 0
I'm trying to do the following:
(2,1)
in a
to the variable p
new
, I want to give it the value 1
For that, I did the following:
p=a(2,1);
new(p)=1;
But, I got the following:
In an assignment A(I) = B, a matrix A cannot be resized.
It seems that also p=a(2,1);
assigns the value at that location and not the location itself.
How can I solve this issue?
Thanks.
La solution
If you want the "location" you can use the linear index of that pixel:
p = sub2ind( size(a), 2, 1 );
new(p) = 1;