thank you for answer but i need to use b and c to ricreate matrix..
is this a homework assignment? maybe you should provide the complete bounds of what you want to do and we can provide some guidance. otherwise we may just propose more ways that won't work for you. in particular, if you read "help find", you'll learn that if you get three vectors from find you can recreate it as a sparse matrix:
>> help find
"...
If three outputs are requested, 'find' also returns a vector
containing the nonzero values. For example:
[i, j, v] = find (3 * eye (2))
=> i = [ 1; 2 ]
=> j = [ 1; 2 ]
=> v = [ 3; 3 ]
Note that this function is particularly useful for sparse matrices,
as it extracts the nonzero elements as vectors, which can then be
used to create the original matrix. For example:
sz = size (a);
[i, j, v] = find (a);
b = sparse (i, j, v, sz(1), sz(2));
"