フィルターのクリア

Adding a single number to an entire matrix

127 ビュー (過去 30 日間)
David Krouse
David Krouse 2021 年 5 月 13 日
編集済み: David Ebert 2023 年 2 月 4 日
How do you add a single number to each element within a matrix?
i.e.
a = 5
b = (1,2,3;4,5,6;7,8,9)
c = a + b

回答 (1 件)

Star Strider
Star Strider 2021 年 5 月 13 日
Exactly as you wrote it!
a = 5
a = 5
b = [1,2,3;4,5,6;7,8,9]
b = 3×3
1 2 3 4 5 6 7 8 9
c = a + b
c = 3×3
6 7 8 9 10 11 12 13 14
Use square brackets [] to code vectors and matrices.
  5 件のコメント
Walter Roberson
Walter Roberson 2023 年 2 月 4 日
What is
size(s_combined_projected_tc_and_predicted_sw)
size(s_get_projected_MMSL)
at the time of the problem?
David Ebert
David Ebert 2023 年 2 月 4 日
編集済み: David Ebert 2023 年 2 月 4 日
Oh, I have made a mistake. I'm sorry. One of the values was not found, giving an empty vector, no wonder.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by