Skip to main content
19-Tanzanite
Aug 1, 2023 1:30 PM UTC
Solved

How to form a matrix with variables defined with range?

Hello,

 

Cornel_2-1690896345105.png

Cornel_7-1690896587948.png

 

Cornel_0-1690896207377.png

 

Cornel_1-1690896213742.png

 

I want that x and y to be in a single matrix with 2 columns:

Cornel_5-1690896472250.png

 

Cornel_6-1690896565687.png

 

Werner_E
Werner_EAnswer
25-Diamond I
Aug 1, 2023 10:28 PM UTC

Nice idea!

Your approach works OK as long as "last" is not actually a member of the result vector

Werner_E_0-1690928776568.png

but it fails if it is

Werner_E_1-1690928817010.png

For the example given it works OK, though,

Werner_E_2-1690928873701.png

but the reason is a round-off error which forces ceil to return the correct number 401

Werner_E_3-1690928921702.png

Using floor(...)+1 instead of ceil(...) should fix it (unless we find an example with a numerical inaccuracy in the opposite direction)

 

EDIT: And the example wasn't hard to find. Both your versions (the orginal with ceil(..) and the suggested fix with floor(..)+1) fail and also my version fails 😞

Werner_E_0-1690929745699.png

 

A possible fix might be to to round to something like 7 decimals first and only then apply  floor(...), or trunc(...) .

Werner_E_1-1690930026868.png

 

 

 

 

 

12 replies

ttokoro
21-Topaz I
Aug 1, 2023 1:41 PM UTC

image.png

Translate
t.t.
Cornel19-TanzaniteAuthor
19-Tanzanite
Aug 1, 2023 1:51 PM UTC

Cornel_0-1690897858985.png

Cornel_1-1690897900796.png

 

 

Translate
terryhendicott
21-Topaz II
Aug 1, 2023 2:51 PM UTC

Capture.JPG

Translate