Comparing matrices and filling in the gaps
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Rik
el 23 de Oct. de 2020
Editada: Rik
el 23 de Oct. de 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.
Respuestas (1)
Peter Perkins
el 20 de Nov. de 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 comentarios
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!