フィルターのクリア

Comparing every value in a numeric array to one value in another one

1 回表示 (過去 30 日間)
Thomas Veith
Thomas Veith 2019 年 6 月 6 日
コメント済み: Star Strider 2019 年 6 月 6 日
Hi all,
Let's say I have a 10x1 numeric array and another one which is 82x3. What I'd like to do is create a new 10x1 matrix which is comprised of the differences between all the entries in my original 10x1 and the 9th entry of the 2nd column of my 82x3. So each entry in the new 10x1 would be a value from the original 10x1 minus the 9th entry of the 2nd column in my 82x3 array. How can I do this?
Thanks in advance!

採用された回答

Star Strider
Star Strider 2019 年 6 月 6 日
Try this:
A = rand(10,1);
B = rand(82,3);
Result = A - B(9,2);
It automatically expands the scalar to the size of the vector, then does the subtraction.
  2 件のコメント
Thomas Veith
Thomas Veith 2019 年 6 月 6 日
Perfect as always! Thank you! Wish I could buy you a pizza or something!
Star Strider
Star Strider 2019 年 6 月 6 日
As always, my pleasure!
Mmmmm ... pizza!

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

その他の回答 (0 件)

カテゴリ

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