필터 지우기
필터 지우기

Array processing operation and summation

조회 수: 1 (최근 30일)
Rui Hou
Rui Hou 2021년 4월 12일
댓글: Rui Hou 2021년 4월 12일
Hi,
I need to read in an integer N from the keyboard and then use array processing operation andsummation to compute the value of the expression.
The expression is ((n+1)/sqrt(n)+n^3)
  댓글 수: 2
KSSV
KSSV 2021년 4월 12일
What have you attempted for your home work?
Rui Hou
Rui Hou 2021년 4월 12일
I have already used for and while loop.

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

채택된 답변

Image Analyst
Image Analyst 2021년 4월 12일
Use the sum() function, if that is allowed.
N = input(.................. % TO DO -- you finish it!
% Get n as a vector [1, 2, 3, 4, ..... N]:
n = 1 : N
Now use your equation ((n+1) ./ sqrt(n) + n .^ 3) , passing it into sum().
Or don't assign n like that, and have a for loop over n and have the equation inside the for loop.

추가 답변 (1개)

KSSV
KSSV 2021년 4월 12일
To achieve this you need to read about input and for loop.
  1. Use input and enter the value of N.
  2. Initialize the required sum value to zero.
  3. Run a d for loop from n = 1 to N, inside the loop calculate your formula and sum using the above initliazed value.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by