How can i pull a matrix out of matrix with indices?
1 view (last 30 days)
Show older comments
Hi everyone. Sorry for the poor expression. I used find() function to find elements, which fulfill certain condition (non constant) . I want to have a matrix of same dimension, which contains the rest of elements in Matrix (constant) . Here is my code. But it runs incredibly long, because dimension of thisMatrix{1} is 30000 * 30000 big. How can i do this faster?
Mat_nonconst_tmp = sparse(size(thisMatrix{1}, 1), size(thisMatrix{1}, 2));
for n = 1:length(row_nonconst)
Mat_nonconst_tmp(row_nonconst(n), column_nonconst(n)) = thisMatrix{1}(row_nonconst(n), column_nonconst(n));
end
Mat_const = thisMatrix{1} - Mat_nonconst_tmp;
0 Comments
Accepted Answer
Matt J
on 16 Jun 2023
Do it a completely different way. Example
A=rand(5)
B=rand(5)
condition=A<0.5;
B(condition)=0
0 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!