How can i pull a matrix out of matrix with indices?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jiahong Zou
am 16 Jun. 2023
Beantwortet: Matt J
am 16 Jun. 2023
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 Kommentare
Akzeptierte Antwort
Matt J
am 16 Jun. 2023
Do it a completely different way. Example
A=rand(5)
B=rand(5)
condition=A<0.5;
B(condition)=0
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sparse Matrices finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!