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

The Archive Base Latest Questions

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

I am building a nxn matrix in matlab with the following code: x =

  • 0

I am building a nxn matrix in matlab with the following code:

x = linspace(a,b,n);

for i=1:n
    for j=1:n
        A(i,j) = x(j)^(i-1);
    end
    A
    i
    b(i) = (1/i)*x(n)^i - (1/i)*x(1)^i;
end

I am testing it with a=1 b=10 and n=10. I get the expected results up to i=8

i =

 8

A =

Columns 1 through 7

       1           1           1           1           1           1           1
       1           2           3           4           5           6           7
       1           4           9          16          25          36          49
       1           8          27          64         125         216         343
       1          16          81         256         625        1296        2401
       1          32         243        1024        3125        7776       16807
       1          64         729        4096       15625       46656      117649
       1         128        2187       16384       78125      279936      823543
       1         256        6561       65536      390625     1679616     5764801

Columns 8 through 10

       1           1           1
       8           9          10
      64          81         100
     512         729        1000
    4096        6561       10000
   32768       59049      100000
  262144      531441     1000000
 2097152     4782969    10000000
16777216    43046721   100000000

however from i=9 on it becomes this:

i =

 9

A =

1.0e+09 *

Columns 1 through 9

0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000
0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000
0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000
0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000
0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000
0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0001
0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0001    0.0003    0.0005
0.0000    0.0000    0.0000    0.0000    0.0001    0.0003    0.0008    0.0021    0.0048
0.0000    0.0000    0.0000    0.0001    0.0004    0.0017    0.0058    0.0168    0.0430
0.0000    0.0000    0.0000    0.0003    0.0020    0.0101    0.0404    0.1342    0.3874

Column 10

0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0010
0.0100
0.1000
1.0000

Can someone please tell me what is happening? I am not very experienced in matlab (I mostly use c++ or python) and so far can’t seem to figure it out myself.

  • 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-27T06:26:43+00:00Added an answer on May 27, 2026 at 6:26 am

    It’s just a formatting issue for larger numbers. Try

    sprintf('%20.0f', A(end,end))
    

    and you will see that the number is correct. At least up to some point, where you will run into double representation problems…

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

Sidebar

Related Questions

Building a string for post request in the following way, var itemsToAdd = sl.SelProds.ToList();
Building my code (below) returns error 'imread' is not a member of 'cv' .
When building a VS 2008 solution with 19 projects I sometimes get: The GenerateResource
Building an overly fancy HTML mail for a client. Code validates at http://validator.w3.org as
building a simple calculator here to get my feet wet with iOS dev. I
Building a GTK+ widget dynamically from code allows for easy access to the child
Building a python fuse fs, in my readdir generator the first line of code
Building an app using the Facebook iOS SDK. When testing on the simulator, I
Building simple code (example is below) returns error on eclipse, while g++ from commandline
Building an application, before using a real database, just to get things work I

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.