フィルターのクリア

adding a value until a particular value

2 ビュー (過去 30 日間)
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017 年 2 月 25 日
Hi,
questions never end!
I have an array 17x365 and some initial values in the first row.
So I would like to add a particular number in every column like this: example First element in each row=[1], I an external value (let's say 2).
So I would add the value 0.52 in each time step like this [1 ; 1.52; 2.04; 2.56;3;3;3;.....]
I add the value 2, in small amount of 0.52 until it is depleted and then take the final value (3) and put it in the rest of the column
I don't know if I explained it well
please help!!
thanks>>!

採用された回答

Stephen23
Stephen23 2017 年 2 月 26 日
>> stp = 0.52; % step
>> ini = [1,4,2,0]; % initial value
>> mxv = [3,7,4,3]; % max value
>> num = 10; % number of rows
and now generate the matrix:
>> vec = stp*(0:num-1).';
>> mat = bsxfun(@plus,ini,vec);
>> mat = bsxfun(@min,mat,mxv)
mat =
1 4 2 0
1.52 4.52 2.52 0.52
2.04 5.04 3.04 1.04
2.56 5.56 3.56 1.56
3 6.08 4 2.08
3 6.6 4 2.6
3 7 4 3
3 7 4 3
3 7 4 3
3 7 4 3
  1 件のコメント
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017 年 2 月 26 日
thanks a lot!!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by