how to add and substract manually in a matrix?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!