Error using vertcat, dimensions of arrays being concatenated are not consistent
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lucas
el 16 de Nov. de 2022
Comentada: Lucas
el 16 de Nov. de 2022
Results = [beamontime; beamofftime; dwelltime; avgxbeam; avgybeam; avgbeam; avgxcentroid; avgycentroid; jitter; avgpower; avgpeakirr; framerate; dwellframerate];
Name = [ 'Beam On (UTC)'; 'Beam Off (UTC)'; 'Dwell Time (s)'; 'Average X-Diameter (cm)'; 'Average Y-Diameter (cm)'; 'Average Diameter (cm)'; 'Average X-Centroid (cm)'; 'Average Y-Centroid (cm)'; 'Jitter (cm)'; 'Average Power (kW)'; 'Average Peak Irradiance (W/cm^2)'; 'Frame Rate (Hz)'; 'Dwell Time Frame Rate (Hz)'];
T = table(Name, Results)
I have two arrays with 1 column and 13 rows. I am trying to make a 2 column table with the names on the left and results on the right. The first 3 results are durations and the rest are double values. Please help, I feel like making tables is so hard on Matlab!
1 comentario
Stephen23
el 16 de Nov. de 2022
"The first 3 results are durations and the rest are double values."
You will have to store these in a container array, e.g. a cell array, because table columns/variables must be one homogenous data type. Mixing data types like this is probably not the best use of a table.
"Please help, I feel like making tables is so hard on Matlab!"
The error message you get is due to concatenating together incompatible char vectors. It is unrelated to tables.
Respuesta aceptada
Stephen23
el 16 de Nov. de 2022
Editada: Stephen23
el 16 de Nov. de 2022
Use a string array rather that trying to vertically concatenate incompatible character vectors:
Name = ["Beam On (UTC)"; "Beam Off (UTC)";..];
% ^ ^ ^ ^ string scalars, not character vectors.
2 comentarios
Stephen23
el 16 de Nov. de 2022
Tested:
Name = ["Beam On (UTC)"; "Beam Off (UTC)"; "Dwell Time (s)"];
Results = [1;4;pi];
T = table(Name,Results)
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays 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!