Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Sparse matrix from non-integers

Subject: Sparse matrix from non-integers

From: Florian

Date: 4 Jun, 2014 10:37:11

Message: 1 of 2

I have unevenly spaced data which I would like to arrange in a sparse matrix. The data are in vectors and the individual values therein are numbers with decimals, not integers.
The sparse function would be the ideal function, but it does not work with values that have decimals.
Is there another function to create a sparse matrix with non-integers?

Subject: Sparse matrix from non-integers

From: Steven Lord

Date: 4 Jun, 2014 14:23:26

Message: 2 of 2


"Florian" <florian_maurerDELETE@yahoo.com> wrote in message
news:lmmssn$rmi$1@newscl01ah.mathworks.com...
> I have unevenly spaced data which I would like to arrange in a sparse
> matrix. The data are in vectors and the individual values therein are
> numbers with decimals, not integers.
> The sparse function would be the ideal function, but it does not work with
> values that have decimals.
> Is there another function to create a sparse matrix with non-integers?

Both sparse and full matrices can accept noninteger values as the _data_,
but neither can accept noninteger values for the _indices_. If that's what
you're trying to do (store something as the 2.5th element of a variable)
you're probably going to need to use a containers.Map object or perhaps
create a scatteredInterpolant object or something similar.

x = 1:10;
% The data in S and A are noninteger values, but they are located at integer
coordinates
S = sparse(x, 11-x, sqrt(x+2))
A = full(S)

http://www.mathworks.com/help/matlab/ref/containers.map-class.html

http://www.mathworks.com/help/matlab/ref/scatteredinterpolant-class.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us