Use these values and Matlab to find the sum of the 161st and 271st values of x

2 views (last 30 days)
x= [70, 10, 41, 65, 99, 55, 52, 26, 69, 27, 55, 98, 35, 59, 58, 89, 66, 31, 70, 51, 73, 80, 27, 97, 38, 71, 17, 88, 67, 23, 67, 38, 24, 98, 93, 23, 54, 46, 39, 24, 63, 85, 22, 88, 44, 70, 78, 11, 92, 49, 53, 65, 30, 70, 62, 58, 42, 70, 47, 10, 84, 15, 38, 98, 14, 31, 22, 58, 68, 52, 73, 32, 37, 85, 20, 72, 56, 89, 74, 48, 39, 27, 14, 59, 88, 67, 18, 31, 37, 56, 31, 22, 61, 60, 20, 65, 82, 33, 24, 50, 75, 88, 72, 13, 73, 83, 75, 30, 73, 49, 68, 12, 67, 72, 62, 56, 40, 70, 77, 67, 27, 99, 80, 78, 59, 90, 44, 42, 24, 59, 82, 90, 47, 55, 93, 21, 38, 69, 41, 11, 18, 10, 14, 76, 73, 66, 33, 13, 37, 10, 71, 54, 10, 51, 33, 60, 42, 68, 92, 56, 27, 74, 46, 65, 30, 40, 76, 58, 99, 18, 60, 18, 18, 64, 84, 82, 30, 17, 85, 58, 18, 56, 12, 18, 98, 35, 68, 40, 93, 61, 87, 21, 36, 33, 76, 56, 63, 53, 14, 63, 62, 64, 71, 71, 29, 56, 53, 49, 63, 38, 98, 72, 85, 10, 81, 83, 36, 50, 23, 29, 11, 10, 41, 37, 34, 18, 83, 88, 62, 88, 51, 24, 53, 22, 85, 72, 68, 39, 22, 32, 67, 20, 95, 53, 20, 76, 36, 46, 27, 50, 66, 28, 51, 98, 56, 76, 16, 40, 65, 68, 29, 16, 83, 72, 29, 69, 44, 88, 98, 57, 21, 66, 67, 16, 19, 78, 83, 46, 25, 10, 87, 82, 29, 39, 80, 76, 15, 86, 16, 70, 55, 35, 77, 38, 97, 96, 98, 42, 85, 96, 90, 96, 62, 57, 13, 71, 36, 86, 17, 51, 87, 95, 33, 17, 34, 14, 83, 39, 91, 90, 10, 46, 25, 78, 75, 23, 75, 73, 56, 60, 69, 46, 56, 32, 94, 59, 93, 30, 46, 11, 72, 34, 96, 96, 42, 30, 10, 25, 60, 91, 15, 61, 38, 31, 39, 13, 45, 14, 77, 92, 64, 47, 38, 21, 69, 32, 71, 63, 53, 18, 64, 25, 43, 61, 21, 75, 82, 22, 91, 43, 13, 97, 95, 41, 28, 34, 45, 64, 39, 23, 56, 94, 60, 84, 15, 30, 17, 77, 83, 61];

Answers (2)

KSSV
KSSV on 6 Dec 2016
Home work...You have to do it on your own. Read about matrix/ vector indexing. If you have a amtrix A, you can access (i,j) element by A(i,j). If you have a vector X, you can acess any element using X(i), i = 1...n. Where n is length of vector.
Your problem is very easy and straight forward.

Surabhi KS
Surabhi KS on 10 Jun 2021
This is basic MATLAB, the key is to understand how MATLAB works. In order to access say the element of an array X, you call it by X(n). This can be extended to accessing any element (i,j) of a matrix X, as X(i,j).
Now, wrt your problem we need X(161) + X(271), which is the exact syntax as well! It is very intutively written in terms of matrices. Since you have an array/1D matrix you need not worry about the other dimensions.

Community Treasure Hunt

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

Start Hunting!