How to display my outputs which one of them is complex numbers and other ones are just 2 digit number in a vertical form side by side. one is "output" and the other ones is "rows" and "columns" in matlab
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mojgan Soltan
am 6 Mär. 2018
Bearbeitet: Andrei Bobrov
am 6 Mär. 2018
function A= mySparse(A)
nonZeroIndices = A ~= 0;
% Extract those non-zero values into a new variable called output:
output = A(nonZeroIndices)
% Determine their row and column indices:
[rows, columns] = find(nonZeroIndices)
end
How to display my outputs which one of them is complex numbers and other ones are just 2 digit number in a vertical form side by side. one is "output" and the other ones is "rows" and "columns" in matlab. Thanks
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 6 Mär. 2018
Bearbeitet: Andrei Bobrov
am 6 Mär. 2018
lo = imag(A) ~= 0;
output = A(lo);
[rows,cols] = find(lo);
out = table(output,rows,cols);
0 Kommentare
Weitere Antworten (1)
KSSV
am 6 Mär. 2018
A = rand(10,3) ;
idx = randperm(30,10) ;
A(idx) = rand(10,1)+1i*rand(10,1) ;
%%Get complex number positions
[i,j] = find(imag(A)) ;
idx = imag(A)~=0 ;
iwant = [A(idx) i j]
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical 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!