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

4 views (last 30 days)
[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?

Answers (1)

Star Strider
Star Strider on 31 Jan 2022
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 Comments
William Blanch
William Blanch on 31 Jan 2022
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.

Sign in to comment.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!