Adding multiple elements from an array

조회 수: 1 (최근 30일)
Nihal Paul
Nihal Paul 2016년 4월 9일
답변: Roger Stafford 2016년 4월 10일
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.

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 9일
You have 8x8 matrice, then read it from excel, then do whatever you want.

Roger Stafford
Roger Stafford 2016년 4월 10일
A(1:9:55) = 0;
v = sum(A,1);

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by