Array processing operation and summation
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rui Hou
am 12 Apr. 2021
Kommentiert: Rui Hou
am 12 Apr. 2021
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 12 Apr. 2021
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.
Weitere Antworten (1)
KSSV
am 12 Apr. 2021
To achieve this you need to read about input and for loop.
- Use input and enter the value of N.
- Initialize the required sum value to zero.
- Run a d for loop from n = 1 to N, inside the loop calculate your formula and sum using the above initliazed value.
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!