MATLAB: I want write in matrix using for loop but the loop give me the last run data

i want write in matrix using for loop but the loop give me the last run data

A = [];
for i = 1:10
A=ecg_raw_channels(LP_i_raw(i):LT_i_raw(i));
end

Best Answer

It depends if the size of the output is same every time inside the loop. If not better to use a cell.
A = cell(1,10);
for i = 1:10
A{i}=ecg_raw_channels(LP_i_raw(i):LT_i_raw(i));
end
If the output is same always...with specified numbers say n
N = 10 ; % say inside loop length is 10
A = zeros(10,10);
for i = 1:10
A(i,:)=ecg_raw_channels(LP_i_raw(i):LT_i_raw(i));
end