I have downloaded a dataset and loaded it into matlab. the files have the .mat extension. when I see their values through Variable Editor I find something like this:

(26,1)      0.206447341030756
(13,2)      0.098574099069309
(20,2)      0.080611271798447
(26,2)      0.107946926644624
(39,2)      0.127336769393055
(50,2)      0.040181713803106
(64,2)      0.1243316705859

when I use class operator to determine the type of the data it says the data is double! I want to convert it to vector or matrix if it is possible. What is the type of this dataset! I don't even know the name of it to search!


Was it helpful?


It looks like a sparse matrix. These are useful when most of your matrix is filled with zeros - then the zeros don't need to be stored. It works and acts just like a full one most of the time (Different computing times for different functions will be noticeable though. Sometimes beneficial, sometimes not, depending on how the data looks and on the function).

Anyways, if you want to convert between the two you use the sparse and the full functions.

sparse_mat = sparse(A); % if you want to make a "normal" matrix sparse
full_mat = full(sparse_mat);  % vice versa


This looks like a sparse matrix (as opposed to a normal full matrix). See here for some more information. The proper way to check sparsity is via issparse:

A = speye(10); % Or sparse(eye(10))

returns true. But:

B = full(A); % Or eye(10)

returns false. Note that many of Matlab's function do not work for sparse inputs. You may need to convert them to full matrices (if memory permits) using full.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow