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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:44:33+00:00 2026-06-03T03:44:33+00:00

One simple question.. Let’s suppose in Matlab we have a variable: numEntries = 8

  • 0

One simple question..

Let’s suppose in Matlab we have a variable: numEntries = 8

I know “ones” is used to create “1’s matrixes” but what’s the result of the following?

W = ones(1:numEntries);

And,if possible,where I can find a good reference about matrixes in Matlab? I looked in official documentation but it is not so clear to me.

Thank you very much

  • 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-03T03:44:36+00:00Added an answer on June 3, 2026 at 3:44 am

    ones creates a matrix of ones. ones works for any number of dimensions, however if you specify only one argument, you’ll get a square matrix of ones of that size. Otherwise, you’ll get a N-dimensional matrix of ones, N being the number of arguments you give to ones.

    If numEntries is 8, 1:numEntries creates a 1×8 vector 1 2 3 4 5 6 7 8. This vector being given as input to ones, you’ll get a 8-dimensional matrix of ones, in which the size of 1st dimension (vertical) is 1, the size of 2nd dimension (horizontal) is 2, the size of third dimension is 3, and so on, until the 8th dimension, that has size of 8.

    numEntries = 8;
    
    W = ones(1:numEntries);
    

    % To check sizes of each dimension of W:

    size(W)
    
    ans =
    1     2     3     4     5     6     7     8
    

    % To calculate the total number of elements in W:

    prod(size(W))
    
    ans =
        40320
    

    % Edit: to get the number of elements in W, numel(W) is faster than prod(size(W)) :

    numel(W)
    
    ans =
        40320
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is one very simple question(or at least at first sight).Let's say we have
I have a question simple like that: Let user enter some words from keyboard,one
My question is kinda simple... Let's suppose I have two simples tables on a
Hopefully a simple question although one I have found impossible to answer myself using
I have a simple question related to one-line programming. First an example: function test(a)
I have a fairly simple question: how to take one row of cv::Mat and
this time i have a simple question: I have one table, related with himself
Simple question, I think. I have org.springframework.scheduling.quartz.CronTriggerBean triggering one job once a day. Because
I have a simple question hopefully - how does one free memory which was
I just want to know one simple thing in Java. Let's consider the following

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.