I am attempting to create an array with the number of columns equal to a selected bin size. I want each row in the array to use the values in t in sequence. For example, t goes from -4 to 4 in intervals of 0.01 seconds. If the bin width is 6, I would like row 1 to be [-4 -3.99 -3.98 -3.97 -3.96 -3.95], and then row 2 would be [-3.99 -3.98 -3.97 -3.96 -3.95 -3.94]... and this is repeated until the last row at time = 4 seconds. I got the code starting to work, however I only make it to row 364 before I get a subscript assignment mismatch error. Can anyone help me figure out this error?
bin_width = 6;
time_interval = 0.01;
t = -4:time_interval:4;
bin_number = bin_width/2;
t_bin = zeros(length(t),bin_width);
for n = 1:length(t)-bin_width
t_bin(n,:) = [t(n):time_interval: t(n+bin_width-1)];
bin_number = bin_number+1;
n = n+1;
end
The error I am getting is
Subscripted assignment dimension mismatch.
Error in Untitled (line 15)
t_bin(n,:) = [t(n):time_interval: t(n+bin_width-1)];
[4, 4.01,...]or[...3.99, 4]? - zeeMonkeezn=364(not394??) what is the value of[t(n):time_interval: t(n+bin_width-1)]? - Dan