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 7769601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:12:00+00:00 2026-06-01T16:12:00+00:00

I get an error of ??? Subscripted assignment dimension mismatch. when days value reaches

  • 0

I get an error of ??? Subscripted assignment dimension mismatch. when days value reaches 13 because probably legend_vec column size for 7th row reaches 13.

days = [1     2     3     4     5     6    13];
for i=1:nTime
    legend_vec(i,:)=(['After ',num2str(days(i)),' days']);
end

How can I avoid the error and store all days as I am storing in legend_vec? Thanks.

  • 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-01T16:12:01+00:00Added an answer on June 1, 2026 at 4:12 pm

    When you attempt to store the composite string into an array, it will store it as a list of the Ascii or Unicode character numbers. So if I try to insert the string ‘Hello world’ as the first row of an array, then that first row will actually be:

    >>> my_strs = []; 
    >>> my_strs(1,:) = "Hello world"
    my_strs =
    
    72   101   108   108   111    32   119   111   114   108   100
    

    Notice that this implicitly makes my_strs into a 1-by-11 array. If I try to add a string as a second row, but it doesn’t evaluate to have 11 character codes of length, it will give an error:

    >>> my_strs(2,:) = "Hi there"
    error: A(I,J,...) = X: dimensions mismatch
    

    So you either need to add whitespaces to pad the length of all your days when they become strings (so all your strings have uniform length), or do something more convenient, like store all the strings into a cell array where they can have different lengths.

    To do it with a cell array, you would do something like this:

    >>> my_strs = {};
    >>> my_strs{1} = "Hello world"
    my_strs =
    
    {
      [1,1] = Hello world
    }
    
    >>> my_strs{2} = "Hi there"
    my_strs =
    
    {
      [1,1] = Hello world
      [1,2] = Hi there
    }
    
    >>> my_strs{1,1}
    ans = Hello world
    >>> my_strs{1,2}
    ans = Hi there
    

    It should be straightforward to map that onto the index conventions you’re using in the loop you display in the question above.

    Full disclosure: I am testing the above code using Octave, because I personally prefer to boycott Matlab. You can ask in meta or something if you care about why that is, but for the purposes of this question, I don’t think that testing in Octave makes any difference in what the right answer is.

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

Sidebar

Related Questions

I have this query and I get error Operand should contain 1 column(s), whats
I'm getting this error ev.c:11: error: subscripted value is neither array nor pointer for
I get error: ORA-06575: Package or function GET_CONC_NAMES is in an invalid state When
Why I get error with this query on my live server but not on
What is the best way to get error messages from a WF4 workflow back
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
I am using following PHP code for trigger creation but always get error, please
When we try to create a view within a funcion we get ERROR: there
Whenever i try using php with lighttpd on my iphone i get error 500
If I set pre-compile script into binary code to true I get error saying

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.