フィルターのクリア

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

1 回表示 (過去 30 日間)
Jonas Maurer
Jonas Maurer 2017 年 12 月 13 日
コメント済み: Jonas Maurer 2018 年 1 月 29 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by