a ktensor.</p><pre class="codeinput">rand(<span class="string">'state'</span>,0);
X = sptenrand([5 4 3], 10)
</pre><pre class="codeoutput">X is a sparse tensor of size 5 x 4 x 3 with 10 nonzeros
	(1,4,1)    0.4966
	(2,2,3)    0.8998
	(3,2,3)    0.8216
	(3,3,1)    0.6449
	(3,3,3)    0.8180
	(3,4,1)    0.6602
	(4,1,2)    0.3420
	(4,1,3)    0.2897
	(5,2,2)    0.3412
	(5,3,2)    0.5341
</pre><pre class="codeinput">P = parafac_als(X,2)
</pre><pre class="codeoutput">
CP_ALS:
 Iter  1: fit = 3.219563e-001 fitdelta