필터 지우기
필터 지우기

If A2 and B7´s content were 1 - then how to fill A3 to A6 with ones by function??

조회 수: 1 (최근 30일)
Hi. I´ve described my problem in the picture... My action looked like that:
for m=2:e-a
if X(m,1)==1 || X(1:e-a,3)==1 && X(m,2)==0
X(m,3)=1;
else
X(m,3)=0;
end
end
That should be repeated other way round for Column 4. Problem: I´ve got a glimpse of an idea that MatLab doesn´t like, if i refer to a cell in the output column?! Do you have any other option to fill the cells with ones easier? Thanks very much!
  댓글 수: 1
Jan
Jan 2017년 12월 13일
편집: Jan 2017년 12월 13일
Please note that "cells" mean cell arrays in Matlab. Do you mean "element"?
After inspecting the picture, I have no idea what "That should be repeated other way round for Column 4" might mean. What is "e" and "a"? What does this mean:
I´ve got a glimpse of an idea that MatLab doesn´t like, if i
refer to a cell in the output column?
Do you get an error message?
"A2 and B7´s content" sounds, like you have an Excel problem. Does you question concern Matlab?

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

채택된 답변

Jan
Jan 2017년 12월 13일
편집: Jan 2017년 12월 13일
Maybe you want this:
c1 = (X(:, 1) == 1);
c2 = (X(:, 2) == 1);
X(c2, 1) = -1;
X(c1, 2) = -1;
X(1, :) = max(X(1, :), 0);
Y = cumsum(X, 1);
Or:
match = find([any(X, 2), true]);
index = repelem(match(1:end-1), diff(match));
Y = X(index, :);
UNTESTED - please provide some inputs.
  댓글 수: 1
Jonas Maurer
Jonas Maurer 2018년 1월 29일
Thanks Jan Simon,
your tool fits my question. Thank you very much for that one. I also found a maybe more time consuming way which is seen below. But just to mention this way...
for m=range
if A(m,1) >= 0.9 && B(m,1)==0
C(m,1)=1;
else C(m,1)=0;
end
if C(m-1,1) >= 0.9 && B(m,1) <= 0.9
C(m,1)=1;
end
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by