NDLINSPACE (v1.1, feb 2008)

版本 1.1.0.0 (2.5 KB) 作者: Jos (10584)
Generalized LINSPACE: linearly spaced values between mutliple points
2.4K 次下载
更新时间 2009/2/3

查看许可证

NDLINSPACE - Generalized linearly spaced matrix for multiple points

R = NDLINSPACE(M1,M2, N) returns a matrix of size [size(M1) N] holding
N equally spaced points between corresponding point of M1 and M2. If N
is smaller than 2, M2 is returned. R = NDLINSPACE(M1,M2) uses N = 100.

For scalar inputs, NDLINSPACE(S1,S2,N) mimicks LINSPACE, returning
equally spaced points between the S1 and S2. Example:

ndlinspace(0, 2, 4)
% -> 0 0.67 1.33 2.00

For two M-by-1 column vectors, NDLINSPACE(V1,V2,N) returns a M-by-N
matrix in which the k-th row holds the N equally spaced numbers between
V1(k) and V2(k). Similary, for two 1-by-M row vectors, a N-by-M matrix
is returned. Example:

ndlinspace([0 ; 12 ; 10], [3 ;18 ; 11],4)
% -> 0 1.00 2.00 3.00
% 12.00 14.00 16.00 18.00
% 10.00 10.33 10.67 11.00

For two ND arrays of size P-by-Q-by-R-by-.. matrices, NDLINSPACE
(M1,M2,N) returns a P-by-Q-by-R-by-..-by-N matrix, holding N equally
space points between M1(i,j,k,..) and M2(i,j,k,..). Example:

M1 = reshape(1:2*3*4*5,[2 3 4 5]) ;
M2 = 10 * M1 ;
size(M1) ; % ans = 2 3 4 5
R = ndlinspace(M1,M2,5) ;
squeeze(R(2,1,4,3,:)).'
% ans = 68 221 374 527 680
% Compare with LINSPACE for scalars
linspace(M1(2,1,4,3),M2(2,1,4,3),5)
% ans = 68 221 374 527 680

In general, M1 and M2 have to have the same size. Scalar expansion is
applied when one of the inputs is a scalar. Example:
ndlinspace(0,[4 ; 8 ; -12],5) % expand M1
% ans = 0 1 2 3 4
% 0 2 4 6 8
% 0 -3 -6 -9 -12

See also linspace, logspace, repmat, interp1, squeeze

引用格式

Jos (10584) (2025). NDLINSPACE (v1.1, feb 2008) (https://ww2.mathworks.cn/matlabcentral/fileexchange/22875-ndlinspace-v1-1-feb-2008), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R14
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.1.0.0

fixed minor typos

1.0.0.0