Main Content

unigrid

Description

example

grd = unigrid(startval,stp,endval) returns a uniformly sampled grid from the closed interval [startval,endval], starting from startval. stp specifies the step size. This syntax is the same as calling startval:stp:endval.

example

grd = unigrid(startval,stp,endval,intype) specifies whether the interval is closed, or semi-open.

Examples

collapse all

Create a uniform closed interval grid with a positive increment.

grid = unigrid(0,0.1,1);
grid(1)
ans = 0
grid(end)
ans = 1

Note that grid(1) = 0 and grid(end) = 1.

Create a uniform grid with a semi-open interval.

grid = unigrid(0,0.1,1,'[)');
grid(1)
ans = 0
grid(end)
ans = 0.9000

In this case, grid(end) = 0.9

Create a decreasing grid with a semi-open interval.

grid = unigrid(1,-0.2,0,'[)')
grid = 1×5

    1.0000    0.8000    0.6000    0.4000    0.2000

Input Arguments

collapse all

Start value of the uniform grid, specified as a real scalar.

Data Types: double

End value of the uniform grid, specified as a real scalar.

Data Types: double

Step size, specified as a real scalar

Data Types: double

Interval type, specified as "[]", which represents a closed interval, or "[)", which represents a semi-open interval. Specifying a closed interval does not always cause grd to contain the value endval. The inclusion of endval in a closed interval also depends on the step size stp.

Data Types: char | string

Extended Capabilities

Version History

Introduced in R2011a

See Also

|