how to generate the no. in increasing order but with decreasing difference between the no.?

1 回表示 (過去 30 日間)
eg:- i want to generate the no. from 10 to 40 but i want the no. will generate like
10 20 28 34 40.
in this the no. is generate from 10 to 40 and the difference is decreasing by 2.
  2 件のコメント
Torsten
Torsten 2022 年 9 月 1 日
34 - 28 = 6 and also 40 - 34 = 6, so the difference is not decreasing by 2.
SAHIL SAHOO
SAHIL SAHOO 2022 年 9 月 1 日
sorry not 40, it should be 38

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

採用された回答

Mathieu NOE
Mathieu NOE 2022 年 9 月 1 日
hello
maybe this :
(result : a = 10 20 28 34 38 40)
% init
a(1) = 10;
delta = 10;
iter = 5;
% main loop
for ci = 1:iter
a(ci+1) =a(ci) + delta;
delta = delta -2;
end

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by