Sparse Array - Special Command?
Show older comments
Hi,
I'm dealing with a sparse array. Given 2 arrays "col" and "val", I want to create a one-rowed sparse array of value val(i) in the column col(i), for all i.
What I did is:
if true
% val, col given
leng = length(val);
row = ones(1, leng);
result = sparse(row, col, val, 1, leng);
end
Is there a better way to do, without creating an array "row" in particular? Because getting the length and creating the row take a bit of time in my problem.
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!