Skip to main content
19-Tanzanite
August 1, 2023
Solved

How to form a matrix with variables defined with range?

  • August 1, 2023
  • 1 reply
  • 3670 views

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

 

Best answer by Werner_E

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

 

 

 

 

 

1 reply

ttokoro
21-Topaz I
21-Topaz I
August 1, 2023

image.png

t.t.
Cornel19-TanzaniteAuthor
19-Tanzanite
August 1, 2023

Cornel_0-1690897858985.png

Cornel_1-1690897900796.png

 

 

21-Topaz II
August 1, 2023

Capture.JPG