elmoukrie
Chemical
- Nov 24, 2016
- 1
Hello,
It is about programming on matlab. I have a structure of D elements with their indexes and their values. I want from this structure to calculate a new quantity D'.
For indexes i=1 to p=6, it is simple: D'_i = D_i.
For _i_j_k...to p , it is more complicated. D'_i_j_k...to p = D_i_j_k...to p - sum All D_i_j_k...to p-1 - sum All D_i_j_k - sum All D_i_j - sum All D_i.
It is better to see these three examples to understand:
D'_1_4 = D_1_4 - D_1 -D_4
D'_1_3_5 = D_1_3_5 - D_1_3 - D_1_5 - D_3_5 - D_1 - D_3 - D_5
D’_1_2_3_4_5_6 = D_1_2_3_4_5_6 – (D_1_2_3_4_5 + D_1_2_3_4_6 + D_1_2_3_5_6 + D_1_2_4_5_6 + D_1_3_4_5_6 + D_2_3_4_5_6)- (D_1_2_3_4 + D_1_2_3_5- D_1_2_3_6 + D_2_3_4_5 + D_2_3_4_6 + D_3_4_5_6 )- (D_1_2_3 + D_1_2_4 + D_1_2_5 + D_1_2_6 + D_2_3_4 + D_2_3_5 + D_2_3_6+ D_3_4_5 + D_3_4_6 ) – (D_1_2 + D_1_3 + D_1_4 + D_1_5 + D_1_6 + D_2_3 + D_2_4 + D_2_5 + D_2_6 + D_3_4 + D_3_5 + D_3_6 + D_4_5 + D_4_6) – ( D_1 + D_2 + D_3 + D_4 + D_5+ D_6)
I hope get a new structure r' which is the same bu with D'_. Thanks before.
r =
struct with fields:
D_1: 79.3927
D_2: 141.8463
D_3: -126.6688
D_4: 167.2028
D_5: 547.2340
D_6: 10.5369
D_1_2: 98.8763
D_1_3: -140.9858
D_1_4: 95.0552
D_1_5: 458.3821
D_1_6: -48.7647
D_2_3: -107.6000
D_2_4: 170.8630
D_2_5: 409.5086
D_2_6: 54.4450
D_3_4: -128.2986
D_3_5: 798.2442
D_3_6: -157.5395
D_4_5: 543.9655
D_4_6: 41.6689
D_5_6: 326.9267
D_1_2_3: -112.3449
D_1_2_4: 116.5339
D_1_2_5: 366.5535
D_1_2_6: 0.8760
D_1_3_4: -140.3052
D_1_3_5: 752.5296
D_1_3_6: -175.7908
D_1_4_5: 480.4113
D_1_4_6: -36.4595
D_1_5_6: 249.4541
D_2_3_4: -95.5353
D_2_3_5: 754.1615
D_2_3_6: -138.5796
D_2_4_5: 433.9207
D_2_4_6: 69.7545
D_2_5_6: 204.5355
D_3_4_5: 794.4483
D_3_4_6: -159.0863
D_3_5_6: 156.7859
D_4_5_6: 326.2838
D_1_2_3_4: -106.1654
D_1_2_3_5: 706.7515
D_1_2_3_6: -156.7492
D_1_2_4_5: 390.2635
D_1_2_4_6: 32.4656
D_1_2_5_6: 168.7679
D_1_3_4_5: 752.4031
D_1_3_4_6: -174.2566
D_1_3_5_6: 135.9873
D_1_4_5_6: 268.3483
D_2_3_4_5: 763.9713
D_2_3_4_6: -124.6966
D_2_3_5_6: 104.4331
D_2_4_5_6: 221.9732
D_3_4_5_6: 166.1050
D_1_2_3_4_5: 712.0376
D_1_2_3_4_6: -148.4679
D_1_2_3_5_6: 81.4154
D_1_2_4_5_6: 189.4950
D_1_3_4_5_6: 135.4077
D_2_3_4_5_6: 114.0186
D_1_2_3_4_5_6: 86.0936
It is about programming on matlab. I have a structure of D elements with their indexes and their values. I want from this structure to calculate a new quantity D'.
For indexes i=1 to p=6, it is simple: D'_i = D_i.
For _i_j_k...to p , it is more complicated. D'_i_j_k...to p = D_i_j_k...to p - sum All D_i_j_k...to p-1 - sum All D_i_j_k - sum All D_i_j - sum All D_i.
It is better to see these three examples to understand:
D'_1_4 = D_1_4 - D_1 -D_4
D'_1_3_5 = D_1_3_5 - D_1_3 - D_1_5 - D_3_5 - D_1 - D_3 - D_5
D’_1_2_3_4_5_6 = D_1_2_3_4_5_6 – (D_1_2_3_4_5 + D_1_2_3_4_6 + D_1_2_3_5_6 + D_1_2_4_5_6 + D_1_3_4_5_6 + D_2_3_4_5_6)- (D_1_2_3_4 + D_1_2_3_5- D_1_2_3_6 + D_2_3_4_5 + D_2_3_4_6 + D_3_4_5_6 )- (D_1_2_3 + D_1_2_4 + D_1_2_5 + D_1_2_6 + D_2_3_4 + D_2_3_5 + D_2_3_6+ D_3_4_5 + D_3_4_6 ) – (D_1_2 + D_1_3 + D_1_4 + D_1_5 + D_1_6 + D_2_3 + D_2_4 + D_2_5 + D_2_6 + D_3_4 + D_3_5 + D_3_6 + D_4_5 + D_4_6) – ( D_1 + D_2 + D_3 + D_4 + D_5+ D_6)
I hope get a new structure r' which is the same bu with D'_. Thanks before.
r =
struct with fields:
D_1: 79.3927
D_2: 141.8463
D_3: -126.6688
D_4: 167.2028
D_5: 547.2340
D_6: 10.5369
D_1_2: 98.8763
D_1_3: -140.9858
D_1_4: 95.0552
D_1_5: 458.3821
D_1_6: -48.7647
D_2_3: -107.6000
D_2_4: 170.8630
D_2_5: 409.5086
D_2_6: 54.4450
D_3_4: -128.2986
D_3_5: 798.2442
D_3_6: -157.5395
D_4_5: 543.9655
D_4_6: 41.6689
D_5_6: 326.9267
D_1_2_3: -112.3449
D_1_2_4: 116.5339
D_1_2_5: 366.5535
D_1_2_6: 0.8760
D_1_3_4: -140.3052
D_1_3_5: 752.5296
D_1_3_6: -175.7908
D_1_4_5: 480.4113
D_1_4_6: -36.4595
D_1_5_6: 249.4541
D_2_3_4: -95.5353
D_2_3_5: 754.1615
D_2_3_6: -138.5796
D_2_4_5: 433.9207
D_2_4_6: 69.7545
D_2_5_6: 204.5355
D_3_4_5: 794.4483
D_3_4_6: -159.0863
D_3_5_6: 156.7859
D_4_5_6: 326.2838
D_1_2_3_4: -106.1654
D_1_2_3_5: 706.7515
D_1_2_3_6: -156.7492
D_1_2_4_5: 390.2635
D_1_2_4_6: 32.4656
D_1_2_5_6: 168.7679
D_1_3_4_5: 752.4031
D_1_3_4_6: -174.2566
D_1_3_5_6: 135.9873
D_1_4_5_6: 268.3483
D_2_3_4_5: 763.9713
D_2_3_4_6: -124.6966
D_2_3_5_6: 104.4331
D_2_4_5_6: 221.9732
D_3_4_5_6: 166.1050
D_1_2_3_4_5: 712.0376
D_1_2_3_4_6: -148.4679
D_1_2_3_5_6: 81.4154
D_1_2_4_5_6: 189.4950
D_1_3_4_5_6: 135.4077
D_2_3_4_5_6: 114.0186
D_1_2_3_4_5_6: 86.0936