How can i pull a matrix out of matrix with indices?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Matt J
il 16 Giu 2023
Do it a completely different way. Example
A=rand(5)
B=rand(5)
condition=A<0.5;
B(condition)=0
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Sparse Matrices in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!