Need help with for and while loops.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Christian Maynard
le 23 Mar 2015
Commenté : Christian Maynard
le 23 Mar 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.
0 commentaires
Réponse acceptée
James Tursa
le 23 Mar 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:
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!