# recreate array original

6 messages
Open this post in threaded view
|

## recreate array original

 hi, look this: a=[2 6 1;2 5 8;3 1 6] [b,c]=find(a>3); b= 1     2     2     3 c=  2      2      3      3 d=zeros(size(a)); I want to write a new matrix of zeros but keeping the values ​​found with find 0 6 0 0 5 8 0 0 6 any help me?^ thank  (i see help find but i not found answer) -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Open this post in threaded view
|

## Re: recreate array original

 d = a .* (a > 3)
Open this post in threaded view
|

## Re: recreate array original

 On Thu, Aug 1, 2019 at 2:07 PM Nir Krakauer <[hidden email]> wrote:d = a .* (a > 3)turbofib, recommend you look at what the individual parts of Nir's suggestion do.  it's a combination of logical indexing and elementwise operations.  Also recommend you look up some tips on array, linear, and logical indexing.  see:  https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html
Open this post in threaded view
|

## Re: recreate array original

 In reply to this post by Nir Krakauer-3 On Thu, Aug 1, 2019 at 2:22 PM gigiolone123 <[hidden email]> wrote: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));"