How can i pull a matrix out of matrix with indices?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Matt J
2023-6-16
Do it a completely different way. Example
A=rand(5)
B=rand(5)
condition=A<0.5;
B(condition)=0
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!