I have to insert values from a for loop into the matrix, but the values are all the time getting overwritten, so only last values are added into the matrix. What is the way to add every value to the matrix inside a for loop without overwriting?
My code is this:
%reading the file
list = fopen('intervals.txt','r');C=cell(size(list)) for k=1:length(list) content = fgets(list(k)) d= strsplit(content,',') for n=1:length(d) % d contains 25 elements
B = zeros(n,1); % preallocate, results output
y=d{n} z= strsplit(y,' ') start=z{1} stop=z{2} start1 = str2num(start) stop1 = str2num(stop) B = [start1,stop1] %write to the matrix
end
Best Answer