Intro Matlab Q, floating point system

In summary, the conversation discusses a problem involving a normalized floating point number system with specific values for base, precision, and boundaries. The conversation includes discussions on understanding the numbers and plotting them using MATLAB. Clarification is needed on the number of mantissa digits and how to graph the numbers. Several attempts using MATLAB are mentioned, but it is unclear if they will work for the problem.
  • #1
Laura1321412
24
0

Homework Statement



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

Homework Equations





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
 
Physics news on Phys.org
  • #2
First, eliminate the MATLAB component of your problem and use MS Excel (or equivalent) to do the plot.
 
  • #3
Laura1321412 said:
Consider a normalized floating point number system with b=2 p=3 L=-2 and U=2
What do these numbers represent?
 
  • #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...
 
  • #5
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.
 
  • #6
I need to find them using a function i belive... but i can't determine that function i always get matrix errors...
 
  • #7
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.
 
  • #8
Keep in mind that since the base is 2, the only numbers you can have for a0, a1, and a2 are 0 and 1.
 
  • #9
Laura1321412 said:
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

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

and the overall equations is

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

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^EBTW. 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:
  • #10
My guess is that this exercise doesn't use the implied first mantissa digit. Hopefully the OP will make that clear.
 
  • #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 wouldn't 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
 
  • #12
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.
 
  • #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
 
  • #14
I don't know - try it and see. In any case, I believe that there should be three binary digits, not two, as you show.
 

1. What is the floating point system in Matlab?

The floating point system in Matlab is a method for representing and performing calculations with real numbers using a limited number of digits. It is based on the IEEE 754 standard and is used in many programming languages and scientific applications.

2. How does Matlab handle floating point numbers?

Matlab uses a binary representation of floating point numbers, which means that they are represented as a combination of a sign bit, a mantissa, and an exponent. This allows for a wide range of numbers to be represented, but also introduces some limitations and potential errors in calculations.

3. Can I change the precision of floating point numbers in Matlab?

Yes, Matlab allows you to change the precision of floating point numbers by using the "format" command. You can choose between different formats, such as "short", "long", or "bank", which affect the number of digits displayed in the output. However, the underlying representation of the numbers remains the same.

4. What is the difference between single and double precision in Matlab?

In Matlab, single precision numbers are represented using 32 bits, while double precision numbers use 64 bits. This means that double precision numbers can represent a wider range of values and have a higher precision compared to single precision numbers. However, they also require more memory to store.

5. How can I avoid errors when working with floating point numbers in Matlab?

To avoid errors when working with floating point numbers in Matlab, it is important to understand the limitations of the floating point system and how it can affect calculations. You can also use functions such as "eps" to determine the precision of a number, and use appropriate rounding or formatting methods when displaying results.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
9
Views
955
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
955
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
17
Views
3K
Replies
4
Views
930
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Computing and Technology
Replies
4
Views
768
  • Engineering and Comp Sci Homework Help
Replies
4
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
Back
Top