Azzera filtri
Azzera filtri

Could anyone help me how to solve the issue.

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Matt J
Matt J il 7 Set 2019
[m,n]=size(a);
differences=reshape(a,m,1,n) - reshape(a,1,m,n);
  2 Commenti
madhan ravi
madhan ravi il 7 Set 2019
Modificato: madhan ravi il 7 Set 2019
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))
jaah navi
jaah navi il 10 Set 2019
Modificato: jaah navi il 10 Set 2019
ok.It works.
with respect to the following code,
a=[0.0022;
0.0922;
0.0146;
0.2549];
[m,n]=size(a);
differences = bsxfun(@minus,reshape(a,m,1,n),reshape(a,1,m,n))
v = nonzeros(differences');
newmat = reshape(v,3,4)'
val = max(newmat')
V=val'
i can get the result as
V =[-0.0124;
0.0900;
0.0124;
0.2527]
But i want to display which two rows gives the difference for example first row -third row(1,3) gives -0.0124;second row -first row (2,1)gives 0.0900 and so on. could you please help me on this.
Could you please help me how to find the differences of three number present in three separate rows for example 0.0022-0.0922-0.0146;0.0022-0.0922-0.2549;0.0022-0.0146-0.2549.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by