필터 지우기
필터 지우기

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

조회 수: 14 (최근 30일)
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
Stephen23
Stephen23 2022년 11월 16일
"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.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2022년 11월 16일
편집: Stephen23 2022년 11월 16일
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
Stephen23
Stephen23 2022년 11월 16일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by