how to add and substract manually in a matrix?

1 回表示 (過去 30 日間)
suchismita
suchismita 2014 年 5 月 2 日
編集済み: suchismita 2014 年 5 月 8 日
I have a matrix like
A=[1 1 0.7 1
0.7 1 1 1
1 1 0.7 1]
now i want to addition of each column to be 3 so in first column its total is 2.7. where 3-2.7 = 0.3. i want to divide this 0.3 in rest 1 that is 0.15 to 1st element A(1,1) and A(3,1). same wise i want to do for each column. how shall i do that...plz plz help me....
  3 件のコメント
Nitin
Nitin 2014 年 5 月 2 日
Are you trying to nomalize here?
suchismita
suchismita 2014 年 5 月 2 日
no actually...its a part of my phd work...that i have to check whether i can do this type of manipulation in matlab

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 2 日
A=[1 1 0.7 1
0.7 1 1 1
1 1 0.7 1]
s=3-sum(A);
ii=A==1;
jj=sum(ii);
a=s./jj;
b=bsxfun(@times,ii,a);
b(isnan(b))=0;
B=A;
k=b~=0;
B(k)=A(k)+b(k)
  1 件のコメント
suchismita
suchismita 2014 年 5 月 8 日
編集済み: suchismita 2014 年 5 月 8 日
i have a doubt if i want to edit this same example and assume that after the calculation of 1st column, 2nd column will be calculated from the first....as the subtracting and adding will be done on the value of the previous column.
as for example:
B=[1.15 1.15 0.85 0.85; 0.7 0.7 1.3 1.3; 1.15 1.15 0.85 0.85]

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by