Use a cell array in a for loop
Show older comments
Hi,
I want to be able to loop through data in a nested loop and create an array of values each time I loop round, and store this array in a cell array.
My code is currently:
nrms_data = zeros(48,67); %empty list 48 rows and with 67 columns spaces
for i =(1:67) %this will circle through all the gathers
for j = (1:48)%this will cycle through all the traces in the data for the individual gather
trace_j = data{i}(:,j); % gives j'th trace of the gather_i
good_trace = data{17}(:,j);
NRMS = nrms(good_trace, trace_j);
nrms_data{i}(j)= NRMS;
I thought that this would store the value of NRMS as the j'th column in the cell array nrms_data but the error is
Cell contents assignment to anon-cell array object.
I'm unsure how else to do this. I want to be able to create an array of nrms values for each ith gather and each jth trace and then have a cell array that is 67 columns long with 48 rows.
Accepted Answer
More Answers (0)
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!