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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:07:42+00:00 2026-05-26T13:07:42+00:00

Code for creation of cell arrays taken from: Array of Matrices in MATLAB [Thank

  • 0

Code for creation of cell arrays taken from:
Array of Matrices in MATLAB
[Thank you Hosam Aly!]

The function is:

function result = createArrays(nArrays, arraySize)
    result = cell(1, nArrays);
    for i = 1 : nArrays
        result{i} = zeros(arraySize);
    end
end

My code:

   a=createArrays(49,[9,9]);

    a{1}(1,1) = 0.01 + 1.*rand(1,1);
    a{1}(2,2) = 0.01 + 1.*rand(1,1);
    a{1}(3,3) = 0.01 + 1.*rand(1,1);
    a{1}(4,4) = 0.01 + 1.*rand(1,1);
    a{1}(5,5) = 0.01 + 1.*rand(1,1);
    a{1}(6,6) = 0.01 + 1.*rand(1,1);
    a{1}(7,7) = 0.01 + 1.*rand(1,1);
    a{1}(8,8) = 0.01 + 1.*rand(1,1);
    a{1}(9,9) = 0.01 + 1.*rand(1,1);

I cannot use a{:}(1,1) to refer to all matrices. Matlab finds using { } an unexpected parenthesis when using loops.

I’d like to keep the format as above for the diagonal. What should I do?

  • 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-26T13:07:42+00:00Added an answer on May 26, 2026 at 1:07 pm

    The best thing I can see is just to loop through all your cells:

    for i = 1:49
     a{i}(1,1) = ...
    end
    

    But why use cells when you can just do a 3D matrix?

    a = zeros(49,9,9);
    
    a(:,2,2) = something
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: The entire code and database creation script can be found from http://gitorious.org/scheator .
I've got some (I think) pretty basic code for creating cell content from a
i've the following code for button creation and on action of button , i'm
I have this code for BinaryTree creation and traversal class Node { Integer data;
I am using following PHP code for trigger creation but always get error, please
I'm kinda lost, i need to call some python code after the creation of
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have photo gallery code that does image re-sizing and thumbnail creation. I use
Code : $('#myLink').click(function (e) { e.preventDefault(); ... if (someCondition) { ... code ... }
I wonder how to translate such C++11 code into Boost+visual studio 2008: multydimensional array

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.