Need help with for and while loops.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!