Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Successive Matrix Midpoint Operations
Replies: 5   Last Post: Mar 21, 2013 5:58 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Konstantine

Posts: 34
Registered: 5/3/11
Re: Successive Matrix Midpoint Operations
Posted: Mar 20, 2013 3:51 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> 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 2x-1 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:end-1)' %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!



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.