Need help with for and while loops.

2 ビュー (過去 30 日間)
Christian Maynard
Christian Maynard 2015 年 3 月 23 日
コメント済み: Christian Maynard 2015 年 3 月 23 日
I have two assignments in my programming class that I'm struggling in. Either of them deal with for loops or while loops. The first one that deals with for loops, requires that we write a code that can multiply matrices. Although there are commands that already do this, we must understand how the for loop works and do it for ourselves.
The second one deals with while loops. It is the same concept as the first, but we must write code that completes the bubble sort algorithm. I won't worry about this one for now.
Any direction on help, advice, or answers here, is greatly appreciated.

採用された回答

James Tursa
James Tursa 2015 年 3 月 23 日
Matrix Multiply: Start with the MATLAB doc for this, in particular the formula for the element C(i,j) of the result from this page:
Code up that formula pretty much exactly as it is written, and then wrap it inside a couple of for loops for the i and j.
Bubble Sort: You can look at this page for pseudo code for this algorithm, and then translate it into MATLAB code:
  1 件のコメント
Christian Maynard
Christian Maynard 2015 年 3 月 23 日
Thank you for the help.

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

その他の回答 (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