Help with matrix manipulation
Mostra commenti meno recenti
I have the following in matrix form and I am trying to figure out how to the following:
-Create column H
-Then enter the following into column H
+For H1 sum(1, B:G)
+For H2 sum(1:2, B:G)
+For H3 sum(1:3, B:G)
+Following this trend until I reach row 24
A B C D E F G H
1: 0.05 0 0 0 0 0 0
2: 0.15 1 1 0 4 0 0
3: 0.25 0 0 1 5 0 0
4: 0.35 0 0 0 1 0 0
5: 0.45 0 0 0 1 0 0
6: 0.55 0 0 1 1 0 0
7: 0.65 0 0 0 0 0 1
8: 0.75 0 0 1 1 0 0
9: 0.85 1 0 0 0 0 0
10: 0.95 2 0 0 0 1 0
11: 1.05 0 0 1 0 3 0
12: 1.15 1 0 0 2 1 0
13: 1.25 0 0 0 0 1 0
14: 1.35 1 0 0 0 1 0
15: 1.45 0 0 0 1 0 0
16: 1.55 0 0 0 0 0 0
17: 1.65 0 0 0 0 2 0
18: 1.75 0 0 0 0 0 0
19: 1.85 0 0 0 0 0 0
20: 1.95 0 0 0 0 0 0
21: 2.05 0 0 0 0 0 0
22: 2.15 0 0 0 0 2 0
23: 2.25 1 0 0 0 0 0
24: 2.35 0 0 0 0 0 0
I am unsure how to accomplish this in the most efficient way and would really appreciate the help. Thanks in advance
Risposta accettata
Più risposte (1)
Steven Lord
il 25 Giu 2019
0 voti
Since this seems like it might be a homework assignment, I'm simply going to point to one of the functions that may help you. Take a look at the help and/or the documentation for the cumsum function. That won't get you all the way there, but it will get you partway to the solution and show you other tools that will be useful for the whole solution.
1 Commento
Noah Wilson
il 25 Giu 2019
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!