MATLAB: Extracting values above 0 in an array and putting them in a new array

MATLAB

how can i get a 1×5 array by taking values of non-zero? (e.g. taking the first column and taking the first minimum value greater than zero)?

Best Answer

Hey, you can use the below piece of code for your desired functionality.
a(a<=0)=inf;
minArray = min(a);
If you want to keep the original array unchanged first assign it to a temporary variable and use it to extract the result.