I need to compare fields in two separate structures, and for the identical field indices, change value of another field within one of the structure. Step 1 is comparing the fields. Is there a simple way to compare them?

9 Ansichten (letzte 30 Tage)
I have two structures with multiple fields. I need to compare field A of Structure 1 with field B in structure 2 and find the indices of the same records. For these records, I need to change values in field C in Structure 1 with values in field D in Structure 2. But I am stuck in step 1 of comparing the two fields. I have tried ismember but that didn't work. Is there a simpler way to compare fields in structure?
Thank you.

Akzeptierte Antwort

Rahul
Rahul am 25 Mär. 2017
Bearbeitet: Rahul am 25 Mär. 2017
Okay, this line worked for finding the indices:
[ind, ~]= find(ismember({structure1(:).fieldA}', {structure2(:).fieldB}')

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by