Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Successive Matrix Midpoint Operations
Posted:
Mar 20, 2013 3:51 PM


> A couple of questions/clarifications  First, why wouldn't the first result be: > [1;NaN;NaN;NaN;5;NaN;NaN;NaN;9] > Second, is your vector (matrix) ALWAYS of odd length? Even so, what if its something like: > [1;NaN;NaN;NaN;NaN;NaN;7] > what do you want on the second iteration of: > [1;NaN;NaN;4;NaN;NaN;7] > Do you want: > [1;2.5;2.5;4;5.5;5.5;7]> > or > [1;2;3;4;5;6;7]
Hi!
I have no idea why I put 5.5 that first time around, it would indeed be 5.
The matrix should always divide evenly by twos between midpoints, so I suppose it would always be odd. The matrices will follow a 2x1 pattern, so: 3, 5, 9, 17 length matrix.
I've figured out how to make it work in a clunky way with this 17 length matrix:
%Establish the original matrix POINTS = NaN (17,1); %Populate first and last values: POINTS(1) = 1; POINTS(end) = 17;
%4 iterations for a matrix of length 17 for h = 1:4 idxx = find(~isnan(POINTS(:))); %find the indexes of values cnt = 2; %start a counter for j = idxx(1:end1)' %start from index of 1 to second to last index value x = POINTS(j); %first point y = POINTS(idxx(cnt)); %second point m = mean([x y]); %mean POINTS(mean([j idxx(cnt)])) = m; %location to put new value cnt = cnt+1; %increase count end end
Any input is appreciated!



