Effacer les filtres
Effacer les filtres

Error using vertcat, dimensions of arrays being concatenated are not consistent

14 vues (au cours des 30 derniers jours)
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 commentaire
Stephen23
Stephen23 le 16 Nov 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.

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 16 Nov 2022
Modifié(e) : Stephen23 le 16 Nov 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 commentaires
Stephen23
Stephen23 le 16 Nov 2022
Tested:
Name = ["Beam On (UTC)"; "Beam Off (UTC)"; "Dwell Time (s)"];
Results = [1;4;pi];
T = table(Name,Results)
T = 3×2 table
Name Results ________________ _______ "Beam On (UTC)" 1 "Beam Off (UTC)" 4 "Dwell Time (s)" 3.1416

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by