Calculate sum of series using for

조회 수: 3 (최근 30일)
Angel Hiram Torres Mota
Angel Hiram Torres Mota 2019년 6월 20일
댓글: James Tursa 2019년 6월 20일
I need help to calculate the sum of this example using only for.
Thanks for the help!
  댓글 수: 2
James Tursa
James Tursa 2019년 6월 20일
편집: James Tursa 2019년 6월 20일
What have you done so far? What specific problems are you having with your code? This is a very simple for-loop. Do you know how to write a for-loop?
Angel Hiram Torres Mota
Angel Hiram Torres Mota 2019년 6월 20일
In new to matlab and this is one of my first assignments. Im just confused at the i = m and also confused at what are my inputs. If you can recommend a book of webpage where I can learn more of this, I would also appreciate it.

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 2019년 6월 20일
편집: James Tursa 2019년 6월 20일
Here is an outline to get you started:
a = something; % you put a value here
m = something; % you put a value here
x = something; % you put a value here
y = 0; % the starting y value
for i=1:m % the for-loop indexing
% you put code here to add something to y
end % the end of the for-loop
See the Getting Started tutorials here:
  댓글 수: 3
Angel Hiram Torres Mota
Angel Hiram Torres Mota 2019년 6월 20일
a = input("Value of a: ");
m = input("Value of m: ");
x = input("Value of x: ");
y = 0;
for i=1:m
y = ((a)*(x^i));
end
disp(y)
Like this I suppose?
I apologize again, as I said I'm new to this.
James Tursa
James Tursa 2019년 6월 20일
That's a good start at getting the values in. But in the for-loop, you want to be adding terms into y. The way you have it coded now, you are simply replacing the value of y with a new term. You need to correct the code inside the for-loop.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by