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

  • Home
  • SEARCH
  • 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 6723501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:34:35+00:00 2026-05-26T09:34:35+00:00

So, what I am trying to do is create a variable that holds 50

  • 0

So, what I am trying to do is create a variable that holds 50 lists/arrays. Accessing an element in this variable would return one of the lists. If there are no elements at a given index, I would like it to return [].

My logic to initialize this would be something like:

spectrum_map=[];
for n=1:spectrum_blocks
    spectrum_map=[spectrum_map,[]];
end

However, after doing so, I simply get an empty matrix:

spectrum_map =

     []

What I want to see is something like:

spectrum_map =

     []  []  []  []  [] ....

That way, if I were to access spectrum_map(2), I would see that it is empty. However, instead I would get an error that the index exceeds matrix dimensions.

Is there some other way to do what I am trying to achieve?

  • 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-05-26T09:34:36+00:00Added an answer on May 26, 2026 at 9:34 am

    You can get the effect you’re looking for if you use a cell array instead of a matrix.

    spectrum_map = cell( 1, 50 );
    spectrum_map{50}
    
    ans =
    
         []
    

    If you need to convert back to a matrix later (to perform some math on it, for instance) you can use the cell2mat function.

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

Sidebar

Related Questions

I am trying to create a class that holds a dynamically created variable. My
We are trying to create a web-service that we plan to pass a variable
I am trying to create a rails application that assigns one value to a
I am trying to create a variable that performs a couple of different replacement
I'm trying to understand if it's possible to create a set of variables that
I am running a loop, and I am trying to create a variable each
I'm trying to create a Vista gadget, I've properly stored my Date1 variable and
I am trying create a WCF service that leverages the WPF MediaPlayer on the
I'm trying to create some classes that allow me to retrieve and manipulate a
I am trying to create a csv file using python that is truly Excel-compatible

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.