MATLAB MATLAB question-sum of sequence

  • Thread starter Thread starter Bassalisk
  • Start date Start date
  • Tags Tags
    Matlab Sequence
AI Thread Summary
The discussion focuses on plotting the sum of a geometric series in MATLAB, specifically the equation ∑2^i = 500,000, where i ranges from 0 to n. Participants suggest using a for loop to implement the summation and recommend plotting discrete points for smaller iterations while considering a continuous log graph for larger ranges. The mathematical solution involves using logarithms to find the nearest n for the sum. Resources for MATLAB tutorials are provided to assist in learning the necessary skills. The user expresses a strong commitment to mastering MATLAB for future projects.
Bassalisk
Messages
946
Reaction score
2
So the problem is here:

https://www.physicsforums.com/showthread.php?p=3532161&posted=1#post3532161

And I understand the answer and all, but I want to go further. MATLAB will be main tool for upcoming years so I have to learn.

I want to plot this:

\sum 2^{i}= 500 000

where sum goes from i=0 to n. n are number of iterations i am looking for. First how can make a combination of functions, that plots a sum. Next how can I plot that so its discreet, and only exists for 1 2 3 4...

So my graph contain x-axis which will be representing "i".

And my y-axis should represent the value of the sum. Ergo 1 3 7 15 etc. All up to something close to 500 000(I think this will come close to like 19 iterations)

EDIT: Can anybody show me purely mathematical way to solve the problem stated in the provided post.

\sum_{i=0}^n 2^{i}= 500 000
 
Last edited:
Physics news on Phys.org
The sum (geometric series) is 2n+1 - 1. You can find the nearest n using logs.
 
mathman said:
The sum (geometric series) is 2n+1 - 1. You can find the nearest n using logs.

Thank you.

Anybody on the MATLAB thing yet?
 
Bassalisk said:
Thank you.

Anybody on the MATLAB thing yet?

Here you go:
http://www.mathworks.com/help/techdoc/learn_matlab/f3-27853.html

While you could plot discrete points (see above), if you're going to span a large number of iterations (say, between 1 and 10,000), you should probably just plot a continuous (log) graph.

Now, as for a way to implement the summation, you should probably just a for loop. I'd start with your n_vector, make a twotothen_vector, and then use the for loop to sum. HINT: you do not need to sum from the first entry every single time. If none of these concepts makes sense, I'd start with an introductory programming book.

Implementation is left as an exercise to the reader / poster, following completion of the MATLAB getting started tutorial:
http://www.mathworks.com/help/techdoc/learn_matlab/bqr_2pl.html
 
Last edited by a moderator:
MATLABdude said:
Here you go:
http://www.mathworks.com/help/techdoc/learn_matlab/f3-27853.html

While you could plot discrete points (see above), if you're going to span a large number of iterations (say, between 1 and 10,000), you should probably just plot a continuous (log) graph.

Now, as for a way to implement the summation, you should probably just a for loop. I'd start with your n_vector, make a twotothen_vector, and then use the for loop to sum. HINT: you do not need to sum from the first entry every single time. If none of these concepts makes sense, I'd start with an introductory programming book.

Implementation is left as an exercise to the reader / poster, following completion of the MATLAB getting started tutorial:
http://www.mathworks.com/help/techdoc/learn_matlab/bqr_2pl.html

Thank you! I will try this out. My next few year will be, literally LIVING on MATLAB. Expect more inquires from me. I am determined to get as best as i can in MATLAB.
 
Last edited by a moderator:

Similar threads

Replies
10
Views
3K
Replies
4
Views
4K
Replies
1
Views
2K
Replies
5
Views
3K
Replies
32
Views
4K
Back
Top