1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Intro Matlab Q, floating point system

  1. Sep 16, 2011 #1
    1. The problem statement, all variables and given/known data

    So this should probably be easy, but for some reason I just can't seem to understand matlab, AT ALL. Anywho,

    Consider a normalized floating point number system with b=2 p=3 L=-2 and U=2 , plot all the numbers in this system in a horizontal line, and observe.... lalala

    2. Relevant equations



    3. The attempt at a solution

    I can't not figure out how plot the system! I can't figure out how to enter the system! I undestant floating point numbers, but i just need a hint or two to get started at this question. thankss
     
  2. jcsd
  3. Sep 16, 2011 #2

    lewando

    User Avatar
    Gold Member

    First, eliminate the MATLAB component of your problem and use MS Excel (or equivalent) to do the plot.
     
  4. Sep 16, 2011 #3

    Mark44

    Staff: Mentor

    What do these numbers represent?
     
  5. Sep 16, 2011 #4
    I can't elimate matlab, i am required to use matlab.

    b= base = 2, p = precision L and U are the boundaries of value exponent

    L<E<U

    and the overall equations is

    x= +/- (a0 + a1/b + a2/b^2)*b^E

    So i need to find all the x for the given equation. But do it using matlab...
     
  6. Sep 16, 2011 #5

    Mark44

    Staff: Mentor

    All told, there are only 80 numbers. Do you know how to find them?

    Once you have them, I think that plotting them means drawing a symbol for each of them on the number line.
     
  7. Sep 16, 2011 #6
    I need to find them using a function i belive.... but i can't determine that function i always get matrix errors...
     
  8. Sep 16, 2011 #7

    Mark44

    Staff: Mentor

    Forget matlab for the time being. Can you list the 80 numbers I referred to on a piece of paper? I'm trying to figure out how much of this problem you understand.
     
  9. Sep 16, 2011 #8

    Mark44

    Staff: Mentor

    Keep in mind that since the base is 2, the only numbers you can have for a0, a1, and a2 are 0 and 1.
     
  10. Sep 17, 2011 #9

    uart

    User Avatar
    Science Advisor

    I'm pretty sure that should be [itex]L \le E \le U[/itex]

    I thought "normalized" floating point numbers all used an implied "1" (binary, b-1 in general) as the most significant bit of the mantissa.

    So shouldn't that be more like ([b-1] + a0/b + a1/b^2 + a2/b^3)*b^E


    BTW. Does "p" include the implied mantissa digit or not? I mean are there three mantissa digits plus one implied, or is it two plus one implied? (I'm not sure about this).
     
    Last edited: Sep 17, 2011
  11. Sep 17, 2011 #10

    Mark44

    Staff: Mentor

    My guess is that this exercise doesn't use the implied first mantissa digit. Hopefully the OP will make that clear.
     
  12. Sep 17, 2011 #11
    Hi, yes, i understand the question pretty well i think

    I know that the aj will be 0 or 1, and I thought binary then indicated that, Ao = 1?

    So wouldnt it be x= +/- ( 1 + A1 / 2 + A2 /4 ) 2 ^ E ?

    wouldn't that mean there would be 2*2*2*5 = 40 solns?

    Additionally, I think I can solve for the values of X, one at a time, but in matlab I was trying do it using matricies... ie )

    z [ -1, 1 ]
    A1 [ 0,1]
    A2 [ 0, 1]
    E [ -2, 1,0,1,2,]

    and so on. But i think its pretty clear that this won't work, since i need a way to have it work out all the options... Do i need to make more elaborate matricies? Is there a way to do this simply?

    Sorry for the lack of elaboration in the OP
     
  13. Sep 17, 2011 #12

    Mark44

    Staff: Mentor

    I think you need to get some clarification on this problem from your instructor, about whether the first digit (to the left of the "binary" point) is an implied 1. If so, then each mantissa would look like
    [itex]\pm 1.a_0a_1a_2 \cdot 2^E[/itex]

    If this is what they look like, then there will be 2 * 8 * 5 numbers in all, because of 8 possibilities of the three binary digits, 5 choices for the exponent, and doubling these because of the sign. That makes 80 numbers in all.

    In any case, you can use matlab to fill up a single, one-dimension array with all of the numbers.

    Next, you need to get clarification on what it means to graph them. My earlier thought was that you could display them all (using, say, an * character) at the right location on an appropriate section of the number line. Does the problem statement give any more guidance on what is needed here? If not, check with your instructor.
     
  14. Sep 17, 2011 #13
    why can't i use something like this on matlab?

    for a=0:1
    for c=0:1
    for w=-1:1
    for E=-2:2
    x=w.*(1+ (a/2)+(c/4)).*2.^E
    end
     
  15. Sep 17, 2011 #14

    Mark44

    Staff: Mentor

    I dunno - try it and see. In any case, I believe that there should be three binary digits, not two, as you show.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Intro Matlab Q, floating point system
  1. Floating point format (Replies: 1)

Loading...