Matrix operations

3 visualizzazioni (ultimi 30 giorni)
Papa Orgen
Papa Orgen il 25 Lug 2011
i have an n by i matrix call it B. I want to apply two different operations to B. I want to perform the first operation on elements of B<0 and then perform the other operation to the rest of B. The operations themselves are n by n matrices. How do i do it please?

Risposte (1)

Titus Edelhofer
Titus Edelhofer il 25 Lug 2011
Hi,
use logical indexing:
idx = B<0;
% operate on these indices:
B(idx) = ...;
% and now on those >= 0:
B(~idx) = ...;
Titus

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by