Getting an error when trying to create a 92x1 matrix.

조회 수: 3 (최근 30일)
William Blanch
William Blanch 2022년 1월 31일
댓글: Star Strider 2022년 1월 31일
[242.8;241.4;243.8;243.0;243.6;...
240.0;243.6;242.8;242.2;242.0;...
243.4;242.8;243.4;242.6;239.2;...
240.8;240.6;241.0;239.8;239.2;...
241.2;242.0;238.6;237.2;237.4;...
238.8;239.0;241.8;241.8;239.6,...
239.0;239.8;239.2;241.8;239.2;...
239.2;238.4;238.6;240.0;239.6;...
240.8;241.2;237.8;237.6;236.6;...
238.6;238.0;239.2;238.0;238.4;...
237.4;237.0;238.4;238.4;237.2;...
236.8;237.4;236.8;237.8;238.8;...
235.8;235.2;236.8;238.0;240.4;...
241.4;236.6;235.2;235.2;236.6;...
233.0;235.6;235.2;232.6;232.2;...
233.2;234.6;234.6;235.8;237.2;...
235.0;235.0;237.0;238.6;234.6;...
234.8;235.4;235.2;235.8;236.8;...
235.6;235.6]
??? Error using ==> vertcat
All rows in the bracketed expression must have the same
number of columns.
Disregard the first Matrix I gave.
What am I doing wrong?

답변 (1개)

Star Strider
Star Strider 2022년 1월 31일
The problem is in the sixth row:
238.8;239.0;241.8;241.8;239.6,...
The comma at the end should be a semicolon. The comma creates horizontal concatenation, not vertical concatenation. The horizontal concatenation throws the error.
With that change, it works:
v = [242.8;241.4;243.8;243.0;243.6;...
240.0;243.6;242.8;242.2;242.0;...
243.4;242.8;243.4;242.6;239.2;...
240.8;240.6;241.0;239.8;239.2;...
241.2;242.0;238.6;237.2;237.4;...
238.8;239.0;241.8;241.8;239.6;...
239.0;239.8;239.2;241.8;239.2;...
239.2;238.4;238.6;240.0;239.6;...
240.8;241.2;237.8;237.6;236.6;...
238.6;238.0;239.2;238.0;238.4;...
237.4;237.0;238.4;238.4;237.2;...
236.8;237.4;236.8;237.8;238.8;...
235.8;235.2;236.8;238.0;240.4;...
241.4;236.6;235.2;235.2;236.6;...
233.0;235.6;235.2;232.6;232.2;...
233.2;234.6;234.6;235.8;237.2;...
235.0;235.0;237.0;238.6;234.6;...
234.8;235.4;235.2;235.8;236.8;...
235.6;235.6]
v = 92×1
242.8000 241.4000 243.8000 243.0000 243.6000 240.0000 243.6000 242.8000 242.2000 242.0000
.
  댓글 수: 2
William Blanch
William Blanch 2022년 1월 31일
Thank You Star Strider, I found it at almost the exact time you answered! But it took me longer than you to find my mistake.
Star Strider
Star Strider 2022년 1월 31일
My pleasure!

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

카테고리

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