フィルターのクリア

How to subtract a number from a previous one

2 ビュー (過去 30 日間)
Tino
Tino 2019 年 4 月 18 日
コメント済み: Tino 2019 年 4 月 18 日
given a set of number 1, 0.75, 0.50, 0.6
I want a code that could compute the following given the first value as 1
for instance the code will generate the following answers
n1 = 1
n2 = 0.75 - n1
n3 = 0.5 - n2
n4 = 0.6 - n3
Your answers will be greatly appreciated.
Thanks in advance

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 4 月 18 日
編集済み: Andrei Bobrov 2019 年 4 月 18 日
x = [1;.75;.5;.6];
n = filter(1,[1;1],x);
or
out = tril(toeplitz(x))*(-1).^(2:numel(x)+1).';
or
n = x;
for jj = 2:numel(x)
n(jj) = x(jj) - n(jj-1);
end
  1 件のコメント
Tino
Tino 2019 年 4 月 18 日
Thanks Andrei

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by