Effacer les filtres
Effacer les filtres

How do I get rid of positive or negative values in a cell array?

3 vues (au cours des 30 derniers jours)
Yerzhigit Bapin
Yerzhigit Bapin le 14 Juil 2017
How do I create a cell array that consists of only positive or negative values of another cell array in a for loop?
For example, C is a cell 1x24 cell array consisting of 16x7 matrices. First, I need to get rid of the positive numbers in those matrices, second I need to turn the negative values into positives.
I hope I was clear.
Thanks.
  2 commentaires
KSSV
KSSV le 14 Juil 2017
You want to get rid? That means you want to replace them or remove them? If you remove them then you will not get a matrix, the result would be a vector..what you want ?
Yerzhigit Bapin
Yerzhigit Bapin le 17 Juil 2017
I want to replace them with zeros.

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 17 Juil 2017
Modifié(e) : Jan le 17 Juil 2017
for iC = 1:numel(C)
M = C{iC};
M(M > 0) = 0;
C{iC} = -M;
end

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by