Comparing matrices and filling in the gaps
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
So,
I've got two matrices
a = [A;B;C;D;E;F]; %% The entire list of variables
b = [B;D;F, 5;13;6]; %% A set of data with missing variables and amounts of occurances in second coulmn
How can i get something that gives me something like this...
c = [A;B;C;D;E;F, 0;5;0;16;0;6]
7 Kommentare
Rik
am 23 Okt. 2020
Bearbeitet: Rik
am 23 Okt. 2020
That is not a table of strings, but a cell array of char arrays. These specifics matter. It also isn't valid Matlab syntax, as you have only 1 char array on the first line, and two on the second line.
Please provide correct examples for a and b. We will probably be able to help your create something. The ismember function or the containers.Map data type might be what you're looking for.
Antworten (1)
Peter Perkins
am 20 Nov. 2020
There are just so many things you can do with joins:
>> a = table(["A";"B";"C";"D";"E";"F"]);
>> b = table(["B";"D";"F"], [5;13;6]);
>> outerjoin(a,b,'Key','Var1','Type','left','RightVariables','Var2')
ans =
6×2 table
Var1 Var2
____ ____
"A" NaN
"B" 5
"C" NaN
"D" 13
"E" NaN
"F" 6
0 Kommentare
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!