copying specific elements of an array to another.
11 views (last 30 days)
Hi, I want to copy certain values from an array with a known size to an array with an unspesified size based on the critaria.
So basically, I want to get all values in the array y that are greater than 0.001 to be copied into a seperate array g, but I'm struggling. Thanks in advance!
More Answers (1)
Awais Saeed on 21 Aug 2021
y = reshape(randn(3)/100,1,);
idx = 0;
for col = 1:1:size(y,2)
if (y(col) > 0.001)
idx = idx+1;
g(idx) = y(col); % store values > 0.001 in g
fprintf('%f ', y) % original data
fprintf('%f ', g) % values > 0.001