Need help with for and while loops.

1 Ansicht (letzte 30 Tage)
Christian Maynard
Christian Maynard am 23 Mär. 2015
Kommentiert: Christian Maynard am 23 Mär. 2015
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.

Akzeptierte Antwort

James Tursa
James Tursa am 23 Mär. 2015
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:

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by