Could anyone help me how to solve the issue.
1 次查看(过去 30 天)
显示 更早的评论
I am having a matrix of
a=[0.0022 0.0021;
0.0922 0.0938;
0.0146 0.0143;
0.2549 0.2509]
I want to calculate the difference of each number with other number present in the remaining rows.
for example i want to calculate the difference of 0.0022 with 0.0922,0.0146 and 0.2549(first column numbers)
similarly i want to calculate the difference of 0.0922 with 0.0022 ,0.0146 and 0.2549 (first column numbers)and so on.
In the same manner i want to calculate the difference of 0.0021 with 0.0938,0.0143 and 0.2509 (second column numbers) and so on.
Could anyone please help me on this.
0 个评论
采纳的回答
Matt J
2019-9-7
[m,n]=size(a);
differences=reshape(a,m,1,n) - reshape(a,1,m,n);
2 个评论
madhan ravi
2019-9-7
编辑:madhan ravi
2019-9-7
Nice, since from the previous questions it is known that OP is using version prior to 2016b:
differences = bsxfun(@minus,reshape(a,m,1,n),reshape(a,1,m,n))
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!