Results 1 to 3 of 3

Math Help - matrices / coordinates

  1. #1
    tue
    tue is offline
    Newbie
    Joined
    Feb 2010
    Posts
    2

    matrices / coordinates

    Hi all

    Im all new to this forum. I have a website project where I have run into a math problem.

    My problem is that i get a specifik number (n), which creates a number of boxes in a matrix. The coordinates of each box should be calculated using a formula, but I cant solve it myself.

    The following should be true:

    n=1, x=1, y=1
    n=2, x=2, y=1
    n=3, x=3, y=1
    n=4, x=4, y=1
    n=5, x=1, y=2
    n=6, x=2, y=2
    n=7, x=3, y=2
    n=8, x=4, y=2
    n=9, x=1, y=3

    And so forth

    I need a function which says something:

    If n=something, x=something and y=something.

    The matrix is a 4xZ matrix, where Z depends on the number of entries.
    With 1-4 entries, Z=1, with 5-8 entries, Z=2 etc.

    I can solve it for n=1-4, but then it gets too complicated for me.

    I hope anyone can help or point me in the right direction.

    Thanks a lot :-)
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie eigenvex's Avatar
    Joined
    Feb 2010
    Posts
    19
    Hmm, well, finding y is easy enough:

    y = ceil(n/4);

    (ceiling function rounds the fraction up to the nearest integer).

    You can use this method for x, but you'll have 1 special case.

    x = mod(n, 4); // n % 4

    (Modulus function) but that won't work when n is a multiple of 4, you have to add this special case:

    if(x == 0)
    x = 4;

    So..just to sum up with Matlab code:

    function f = coords(n)

    y = ceil(n/4);
    x = mod(n, 4);
    if(x == 0)
    x = 4;
    end

    end

    Hope that helps!
    Follow Math Help Forum on Facebook and Google+

  3. #3
    tue
    tue is offline
    Newbie
    Joined
    Feb 2010
    Posts
    2
    HI

    Thanks a lot. It worked for me :-)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: March 28th 2011, 10:40 PM
  2. Replies: 10
    Last Post: September 24th 2010, 04:33 AM
  3. Replies: 6
    Last Post: August 30th 2010, 03:34 PM
  4. Covert Cartesian coordinates eq. into Cylindrical coordinates
    Posted in the Differential Geometry Forum
    Replies: 0
    Last Post: August 6th 2010, 06:56 AM
  5. Replies: 6
    Last Post: February 4th 2009, 12:12 AM

Search Tags


/mathhelpforum @mathhelpforum