필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Yerzhigit Bapin
Yerzhigit Bapin 2017년 7월 14일
댓글: Anthony Castellano 2018년 6월 28일
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
KSSV
KSSV 2017년 7월 14일
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 2017년 7월 17일
I want to replace them with zeros.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2017년 7월 17일
편집: Jan 2017년 7월 17일
for iC = 1:numel(C)
M = C{iC};
M(M > 0) = 0;
C{iC} = -M;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by