Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:14:39+00:00 2026-06-06T15:14:39+00:00

I’m trying to create a cell array of cell arrays in Matlab. The code

  • 0

I’m trying to create a cell array of cell arrays in Matlab. The code that I currently have works exactly like I need it to. The problem is basically that if I comment out any line that isn’t the first, middle, or last I get the error:

Error using ==> vertcat
CAT arguments dimensions are not consistent.

I’ve been researching this for awhile, and I found one other person with the exact same problem…

http://www.programmersheaven.com/mb/ctocplusplustomatlab/424275/424275/mysterious-reason-for-cat-error-when-defining-cell-array/

…however, there is no solution to this post.

Here’s my code (the 4s stand for possible integer values the variables hold):

cell = {{4} ...
    {4} ...
    {4} ...
    {4} ...
    {} ...
    {4} ...
    {4} ...
    {4} ...
    {4} ...
    {4 4 4 4} ...
    {4} ...
    {4} ...
    {4} ...
    {4} ...
    {4} ...
    {4 4 4 4} ...
    {5} ...
    {} ...
    {4} ...
    {4} ...
    {} ...
    {} ...
    {} ...
    {} ...
    {} ...
    {} ...
    {} ...
    {} ...
    {} ...
    };

(I can’t get it to look exactly the same here… after every ellipse the code moves to a new line in my version)

Let’s say I comment out the line with the 5 in it. It will always return the concatenation error. Any idea why this is happening?

Thanks in advance,

Nicole

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:14:41+00:00Added an answer on June 6, 2026 at 3:14 pm

    Here’s a smaller example:

    c = {...
        {1}... % you can comment out this line
        {2}... % error when commenting this line
        {3}... % you can comment this line (will make a 2-by-2 array)
        {4}... % error when commenting this line
        {5}... % you can comment out this line
        }
    

    The commented line will be considered an empty line by Matlab. When catenating, one (or several) empty line is equivalent to a semicolon, which would indicate the start of a new row.

    Consequently,

    c = {{1} {2}
    
         {3} {4}}
    

    results in a 2-by-2 array, and is equivalent to

    c = {{1},{2};{3},{4}}
    

    When you put a semicolon after each line

    c = {...
        {1};... 
        {2};... 
        {3};... 
        {4};...
        {5};... 
        }
    

    any commented-out line will be equivalent to a semicolon, and since multiple semicolons are legal (c = {{1};;{2};} works), you can now comment out any number of lines.

    Note that the output is now a n-by-1 instead of 1-by-n array, and that you shouldn’t call it cell, since that is the name of a built-in function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.