how do i set a value to be less than something?

for example i want x<10 so how would i assign values to x to equal values from 0 to less than 10?

댓글 수: 6

What is less than 10? Is 9.999999999999999 less than 10? How many nines do you need, before it is equal to 10?
david
david 2018년 11월 2일
Isn’t there not a way to set it as all values less than 10 like how if we select a range 1:10 it includes all?
Guillaume
Guillaume 2018년 11월 2일
In the mathematical world, there is an infinity of numbers between 1 and 10.
In the computer world, where numbers have finite precision, there are (only!) 14,636,698,788,954,112 doubles between 1 and 10. You would need (only!) about 104 petabytes of memory to store them all.
"to set it [...] it includes all"
What is "it" ?
Remember that computers are not a true representation of mathematics, only an approximation thereof, a model, when you talk about floating point numbers. But, no there is not a simple way to describe the set that we might write mathematically as [0,10), in floating point numbers.
Yes, there are things you could do, depending on what you really intend here. For example, by a very careful choice of an increment, you COULD generate a list of numbers that do not actually reach 10, but fall short by some tiny residual. Or, you could use linspace to generate such a list, that again, goes to only some point that again falls short by some carefully chosen, finite amount.
X =
typecast(typecast(1,'uint64'):typecast(10,'uint64') - 1, 'double') ;
would be the complete list of floating point values starting from 1.0 and ending at the last possible one before 10.0 . As Guillaume indicates, that would be 104 petabytes, when petabytes is used in the sense of 2^50 bytes (2^10 = kilobyte, 2^20 = megabyte, 2^30 = gigabyte, 2^40 = terabyte). Other people would say that petabytes should be considered based upon decimal, e.g., that 10^3 = kilo, 10^6 = mega, 10^9 = giga, 10^12 = tera, 10^15 = peta): with that measurement it would be about 117 of that kind of petabytes.
Original question:
for example i want x<10 so how would i assign values to x to equal values from 0 to less than 10?
so it will be here when he tried to edit it away.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 11월 2일
편집: Walter Roberson 2018년 11월 2일

0 개 추천

X =
typecast(uint64(0):typecast(10,'uint64') - 1, 'double') ;
This will require a system with approximately 50 exabytes of memory, but Yes, it can be done. You just have link together 300 of the HP systems that are the largest publically known in the world at 160 terabytes each.

댓글 수: 2

Correction: it looks like you might only need about 19 exabytes.
Ah, I was off by a factor of 1000: you would have to link together about 28887 of the 160 terabyte systems. This is huge and very very expensive, but it appears that it would be within human manufacturing capabilities. https://www.emc.com/leadership/digital-universe/2014iview/executive-summary.htm

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Interface-Based Instrument Communication에 대해 자세히 알아보기

제품

태그

질문:

2018년 11월 1일

댓글:

2018년 11월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by