how to make a consecutive matrix before and after the decimal point?

1 view (last 30 days)
Hello everyone ,
I have two numbers a=38.656528472900447 and b=43.667495727539006 I want to make an array which start from a to b but I can't do this a:b because I need every number after the decimal point to increase each time for example 38.656528472900447, 38.656528472900448 38.656528472900449 38.656528472900410 and so on ... till 43.667495727539006 and the numbers after the decimal point not static here it is 15 but it might be smaller or larger.. does any one have an idea of doing this?
thank you
  1 Comment
Stephen23
Stephen23 on 10 Jun 2018
Edited: Stephen23 on 10 Jun 2018
38.656528472900447 has seventeen significant digits, so it can't be reliably stored using single or double anyway. Perhaps you could try vpa, download hpf, or scale to uint64.

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 10 Jun 2018
You can use colon notation to specify the increment size. For example
2.12:0.01:2.22
ans =
Columns 1 through 7
2.1200 2.1300 2.1400 2.1500 2.1600 2.1700 2.1800
Columns 8 through 11
2.1900 2.2000 2.2100 2.2200
But as Stephen mentioned, your finite precision floating point number will not be able to provide the precision you require. You will need the symbolic toolbox.
vpa('38.656528472900447'):vpa('0.000000000000001'):vpa('43.667495727539006')
Note that I used a char array as input to vpa() to maintain precision. You can read more on this here. The above statement is theoretically correct but I doubt you will be able to store such large array. The increment size you need will require several petabytes of memory.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!