Code covered by the BSD License  

Highlights from
Linearly spaced multidimensional matrix without loop

4.66667

4.7 | 4 ratings Rate this file 7 Downloads (last 30 days) File Size: 2.05 KB File ID: #22824

Linearly spaced multidimensional matrix without loop

by Steeve AMBROISE

 

29 Jan 2009 (Updated 02 Feb 2009)

Generates a N-dimensional matrix of linearly equally spaced points between the matrices d1 and d2.

| Watch this File

File Information
Description

LINSPACENDIM is a good extension of the Matlab function linspace to any multidimensional elements.

LINSPACENDIM(d1, d2) generates a multi-dimensional
  matrix of 100 linearly equally spaced points between
  each element of matrices d1 and d2.

  LINSPACENDIM(d1, d2, N) generates N points between
  each element of matrices X1 and X2.

      Example:
      d1 = rand(3, 2, 4); d2 = rand(size(d1)); n = 1;

      y = linspaceNDim(d1, d2, n) returns a multidimensional matrix y of
      size (2, 4, 3, 10)

  Class support for inputs X1,X2:
     float: Multidimensional matrix, vector, double, single

--> I do not use Loop! <--

I use an old function that I wrote to make the tensor product of two(2) multidimensional matrices of of any size and any number of dimensions.

Acknowledgements
This submission has inspired the following:
NDLINSPACE (v1.1, feb 2008)
MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
02 Feb 2009 Jos (10584)

>> linspacendim(0,1)
??? Error using ==> cat
CAT arguments dimensions are not consistent.
Error in ==> LINSPACENDIM at 39
y = cat(NDim+1, Sum1 + Sum2, d2);

This error occurs for every 1-by-N-by-M-... matrix. There are some other issues as well. For instance, in the help:
- LINSPACENDIM or LINSPACEMAT?
- n = 1 in the example?

02 Feb 2009 Gigi

I tried it after modifications. It works perfectly.

Fine.

03 Feb 2009 Jos (10584)

The error indeed seems to be fixed.

03 Feb 2009 Youri

Great program!

Jos, you have to change your rating.

Youri.

04 Feb 2009 Jos (10584)  
Please login to add a comment or rating.
Updates
30 Jan 2009

NO LOOP!!!

02 Feb 2009

I fix the bug that occured when the first (or some) dimensions are singletons.

Thanks to Jos for your comments.

Tag Activity for this File
Tag Applied By Date/Time
multidimensional operations Steeve AMBROISE 29 Jan 2009 17:01:24
multidimensional matrices Steeve AMBROISE 29 Jan 2009 17:01:24
linearly spaced Steeve AMBROISE 29 Jan 2009 17:01:24
kronecker tensor product Steeve AMBROISE 29 Jan 2009 17:01:24
linear algebra Steeve AMBROISE 29 Jan 2009 17:01:24
kronecker tensor product Mayowa 22 Jun 2009 01:43:25

Contact us at files@mathworks.com