How to Merge the cells and name?
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
C PRASAD
el 6 de Jul. de 2022
Comentada: C PRASAD
el 6 de Jul. de 2022
I have the data and I would like to name and merge.The above table the data i have, the below table the table i required.
1 comentario
Walter Roberson
el 6 de Jul. de 2022
How does this differ from the previous similar questions you have posted on the topic?
Respuesta aceptada
Chunru
el 6 de Jul. de 2022
datayouhave = rand(8, 5); % replace this with your data
t = array2table(datayouhave, "VariableNames", ["Maths", "Physics", "Politics", "Economy", "English"]);
name = ["AAA", "AAA", "AAA", "BBB", "BBB", "BBB", "CCC", "CCC"]';
t = [array2table(name) t];
t
3 comentarios
Walter Roberson
el 6 de Jul. de 2022
Which MATLAB version are you using?
Try
datayouhave = rand(8, 5); % replace this with your data
t = array2table(datayouhave, 'VariableNames', {'Maths', 'Physics', 'Politics', 'Economy', 'English'});
name = {'AAA', 'AAA', 'AAA', 'BBB', 'BBB', 'BBB', 'CCC', 'CCC'}.';
t = [array2table(name) t];
t
Más respuestas (1)
Walter Roberson
el 6 de Jul. de 2022
You cannot create that kind of table in MATLAB.
In order to have a row name span multiple rows, you will need to create a table with three rows and two variables. The first variable will be the Name. For each row, the second variable must be a complete table.
M = round(randn(15, 5), 1)
varnames = ["Maths", "Physics", "Politics", "Economy", "English"];
T1 = array2table(M(1:5,:), 'VariableNames', varnames);
T2 = array2table(M(6:10,:), 'VariableNames', varnames);
T3 = array2table(M(11:15,:), 'VariableNames', varnames);
names = ["Ramu"; "Rihith"; "Swarmy"];
Output = table('Size', [3 2], 'VariableTypes', ["string", "table"], 'VariableNames', ["Name"; "Marks"]);
Output.Name = names;
Output.Marks = {T1; T2; T3};
Output
Output.Marks{1}
So you can construct the table, but it will not display nicely.
0 comentarios
Ver también
Categorías
Más información sobre Quadratic Programming and Cone Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!