Replace values at certain positions (positions given in an array, as well as new values)

15 ビュー (過去 30 日間)
Sabine Haase
Sabine Haase 2017 年 8 月 11 日
編集済み: Duncan L 2024 年 12 月 18 日
Hello, my problem is the following: I have a Matrix A with a lot of data and some values need to be replaced. I have two additional arrays, one which leads to the positions in A where the new value belongs, and one which contains the new value for the position in A. Can someone help me? Thanks in advance

採用された回答

Adam
Adam 2017 年 8 月 11 日
編集済み: Adam 2017 年 8 月 11 日
A(B) = C;
should work if B are the locations and C the values, provided they are the same length and contain valid indices and all the usual constraints.
  5 件のコメント
Adam
Adam 2019 年 4 月 12 日
My response is still the same! My answer answered the question that was asked. That was its only purpose. If your question were the same then so would the answer be. Since you haven't given an example I don't understand what aspect of your question is different to the original question which was trivial, hence why the answer was trivial.
If you open a question thread then you will likely attract answers from a much wider range of people. Most people other than me won't read this thread and I don't understand your question.
You can keep telling people they are unhelpful as much as you like, but if you are unhelpful in not giving clear details of your own question people are not mind readers.
Duncan L
Duncan L 2024 年 12 月 18 日
編集済み: Duncan L 2024 年 12 月 18 日
I think what they mean that they want to replace only certain indices (specified by logical array B) in the array A from values from array C, not replacing all values from array C.
This can be done by:
A(B) = C(B);

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

その他の回答 (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