Add to Each Element in an Array

11 ビュー (過去 30 日間)
Michaela Wood
Michaela Wood 2018 年 4 月 27 日
回答済み: Walter Roberson 2018 年 4 月 27 日
I know this is quite simple but I am drawing a blank on how to do it. I have an array that is titled t_yr and is (84x30x30), I need to add 120 to each element in the third dimension. Thank you in advance.

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 27 日
There is no difference between adding to each element in the third dimension compared to adding to every element. Not unless you meant something like adding 120 times the page number.
new_t_yr = bsxfun(@plus, t_yr, 120*reshape(1:size(t_yr,3), 1, 1, []));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by