close all; clear; clc;STORE = nan(30,2);for k = 1:2 rows = 4; columns = 3; x = randi([0 3],rows,columns); store = zeros(rows,columns); Xstore = nan(30,2); for j = 1:3 for i = 1:rows store(i,j) = x(i,j); %Xstore = store(store>0)
Xstore = nonzeros(store) STORE(:,k) = Xstore; % This step does not walk, please
end endend
MATLAB: Every iteration gives me a column vector of non zero elements. How to store them, all the columns, in either a single vector or an array? Attached is the sample code.
store non zero elements
Best Answer