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!