How do I use a sum function in a for loop?

9 ビュー (過去 30 日間)
milanna martillaro
milanna martillaro 2015 年 4 月 15 日
編集済み: Image Analyst 2015 年 4 月 15 日
x = [1, 23,43, 72, 87, 56, 98, 33]
Find:
1) Use a for loop to sum the elements in the vector
2) Repeat the previous problem, this time using a while loop
3) Use a for loop to create a vector of the squares of the numbers 1 through 5.
4) Use a while loop to create a vector of the squares of the numbers 1 through 5.
5) Use the primes function to create a list of all the primes below 100. Now use a for loop to multiply adjacent values together.
  2 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 4 月 15 日
Milanna - rather than posting your homework question, why not post what you have tried to solve this problem? See loop control structures for details on how to construct for and while loops.
Andrew Newell
Andrew Newell 2015 年 4 月 15 日

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by