Filter löschen
Filter löschen

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

14 Ansichten (letzte 30 Tage)
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 Kommentar
Stephen23
Stephen23 am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephen23
Stephen23 am 16 Nov. 2022
Bearbeitet: Stephen23 am 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 Kommentare
Stephen23
Stephen23 am 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by