how to make a consecutive matrix before and after the decimal point?
2 次查看(过去 30 天)
显示 更早的评论
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
采纳的回答
Ameer Hamza
2018-6-10
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!