Match columns and fill datasets
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Tanmoyee Bhattacharya
am 11 Jul. 2024
Beantwortet: Star Strider
am 12 Jul. 2024
I have two files. One file has some values like that:
1
1
1
1
1
1
2
2
2
2
2
2
2
3
3
3
3
3
3
Another file has values like that
1 10
2 20
3 30
I have to assign values of 1, 2 and 3 from file 2 to file 1. In file 1 if 1 value is 6 then six 10 values will assign. Like that I have 800 values. If there is any shortcut for that.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Jul. 2024
File_1 = [1
1
1
1
1
1
2
2
2
2
2
2
2
3
3
3
3
3
3];
File_2 = [1 10
2 20
3 30];
Out = accumarray(File_1, File_1, [], @(x){File_2(x,:)})
Result = cell2mat(Out)
disp(Result)
Out{1}
Out{2}
Out{3}
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Files and Folders 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!