Adding multiple elements from an array

1 view (last 30 days)
Nihal Paul
Nihal Paul on 9 Apr 2016
Answered: Roger Stafford on 10 Apr 2016
I have an 8*8 table in an excel file
A
To/From 1 2 3 4 5 6 7 8
1 0.1179 0 0 0 0 0 0 0
2 0.053 0.1949 0 0 0 0 0 0
3 0.0301 0.1159 0.5868 0 0 0 0 0
4 0.0001 0.0005 0.0769 0.8234 0 0 0 0
5 0 0 0.0019 0.1961 0.818 0 0 0
6 0 0 0 0.005 0.1737 0.6902 0.0023 0
7 0 0 0 0.0007 0.0246 0.2707 0.8626 0.0275
8 0 0 0 0.0001 0.0073 0.055 0.3589 1.9761
I wanted to know how I can add all the elements in column 1 except the element (1,1). Similarly, how I can add all the elements in column 2 except (2,2), and so on.
PS: I know how to select the data I need for the first column with xlsread.
eg.
s1=xlsread(filename,1,'B4:B10');
But I don't know how to read data from column 2 without selecting element(2,2). And how to add them.

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 9 Apr 2016
You have 8x8 matrice, then read it from excel, then do whatever you want.

Roger Stafford
Roger Stafford on 10 Apr 2016
A(1:9:55) = 0;
v = sum(A,1);

Community Treasure Hunt

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

Start Hunting!