How to add values from a matrix
2 views (last 30 days)
Show older comments
I have a matrix(1x5)which include the number 1 2 3 4 5. How would I add the numbers to get 15 using matlab version R2011a.
0 Comments
Answers (1)
Jan
on 28 Mar 2012
Welcome to Matlab and to this forum.
This seem to be a homework question. Therefore I will not post a solution, but hints.
At first I suggest to read the Getting Started chapters of the documentation. This is required if you want to work successfully with such a powerful tool like Matlab. There you find explanation for indexing a vector, what can be useful together with a for loop.
In a second step you can search in the documentation for specific terms:
docsearch add
Finally you could be looking for a command, which adds the elements of an array. Be aware, that Matlab and its documentation has been designed to solve such standard tasks as efficient as possible.
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!