Matlab and floating point, function for min n max?

These functions can be useful when working with floating point systems, as they help to avoid errors caused by rounding and truncation. However, it is important to keep in mind that these functions may not always return the exact smallest and largest values, as they are dependent on the specific system being used. In summary, when working with floating point systems in MATLAB, it is important to consider the limitations and potential errors, and to use functions such as realmin and realmax to help mitigate these issues.
  • #1
brandy
161
0
so i found this program MATLAB on the computers at uni. I've been messing around with it. right now I am learning a bit about floating point systems and stuff and i thought it would be cool to write up a function that finds the smallest and largest numbers but turns out its harder than i first thought.
smallest was easy(er)
1*beta^m and I ignore the significant figures hehe, any ideas on how i fix that?

largest is hard. because i can't ignore them k's :S
will something like this work? I am not actually on MATLAB atm so i can't test myself haha.

u = 0.5*beta^(1-k)
c=[0:k-1];
result = sum((beta-1)*beta^M / beta^c)


oi and what's with the realmin realmax stuff, could i actually use that instead?
 
Physics news on Phys.org
  • #2
Yes, you can use the realmin and realmax functions in MATLAB to find the smallest and largest numbers that can be represented in the system. The realmin function returns the smallest positive value that can be represented in the system. The realmax function returns the largest finite value that can be represented in the system.
 

1. What is Matlab and how is it related to floating point numbers?

Matlab is a programming language commonly used in scientific and engineering fields for data analysis, visualization, and mathematical computations. It is related to floating point numbers because it uses the IEEE-754 standard for representing and manipulating real numbers, which are commonly used in scientific calculations.

2. How does Matlab handle floating point numbers in its calculations?

Matlab follows the IEEE-754 standard for handling floating point numbers. This means that it uses a fixed number of bits to represent real numbers, with a certain number of bits reserved for the mantissa (significand) and the rest for the exponent. This allows Matlab to perform accurate and efficient calculations on numbers with a wide range of values.

3. What is the function for finding the minimum value in a set of floating point numbers in Matlab?

In Matlab, the function for finding the minimum value in a set of floating point numbers is called "min". It takes in an array of numbers as an input and returns the smallest value in that array. For example, if we have an array A = [3.2, 5.7, 1.6], the command "min(A)" would return the value 1.6.

4. How can I find the maximum value in a set of floating point numbers using Matlab?

To find the maximum value in a set of floating point numbers in Matlab, you can use the function "max". Similar to "min", it takes in an array of numbers as an input and returns the largest value in that array. For example, if we have an array B = [2.4, 7.2, 4.9], the command "max(B)" would return the value 7.2.

5. Can Matlab handle non-numeric values in its floating point calculations?

No, Matlab is designed to work with numeric values only. If non-numeric values (such as strings or characters) are included in a calculation, Matlab will return an error. It is important to ensure that all values used in Matlab calculations are numeric to ensure accurate and reliable results.

Similar threads

  • Computing and Technology
Replies
4
Views
763
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
569
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
955
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top