compare array and update the array

4 ビュー (過去 30 日間)
Hamda Altamimi
Hamda Altamimi 2019 年 2 月 21 日
コメント済み: Hamda Altamimi 2019 年 2 月 21 日
Student={ 'A';'B';'C'};
marks={100;100;100};
exam name={'D';'A';'C';'B'};
new marks={12;34;23;45};
i want to compare the exam name with the student and if it is the same I want the marks to be updated by the marks already in the new marks
  2 件のコメント
madhan ravi
madhan ravi 2019 年 2 月 21 日
write your expected result explicitly
Hamda Altamimi
Hamda Altamimi 2019 年 2 月 21 日
the result is the (new mark) will be be used to update (marks) according to every student

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

採用された回答

KSSV
KSSV 2019 年 2 月 21 日
Student={ 'A';'B';'C'};
marks={100;100;100};
exam_name={'D';'A';'C';'B'};
new_marks={12;34;23;45};
[c,ia] = ismember(Student,exam_name) ;
marks1 = new_marks(ia)
  3 件のコメント
KSSV
KSSV 2019 年 2 月 21 日
is it possible to update the (marks) that have 100 instead of adding a new (mark1)
Simply use:
marks = new_marks(ia)
if the student name is not there I needed it to be 100 un changed
Do you think the above lines changing the value if student name is not exisitng?
Hamda Altamimi
Hamda Altamimi 2019 年 2 月 21 日
this didnt works it gave me an error
marks = new_marks(ia)
( if the student name is not there I needed it to be 100 un changed
Do you think the above lines changing the value if student name is not exisitng?) I didnt get what you mean

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by