the difference between a value and a set of values

a=( 2743.727 2743.727 2743.727 2743.727 )
b=( 2304.763 2304.763 2402.288 2304.764 2304.764 )
How can I calculate the matrix
c=
11-11 21-11 31-11 41-11
11-21 21-21 31-21 41-12
11-31 21-31 31-31 41-13
11-41 21-41 31-41 41-14
11-51 21-51 31-51 41-15

2 Comments

What does ‘c’ have to do with ‘a’ and ‘b’?
A=( 100 60 70 80 )
B=( 90 50 60 80 100 )
C= 100-90=10 60-90=-30 70-90=-20 80-90=-10
100-50=50 60-50=10 70-50=-20 80-50=-30
100-60=40 60-60=0 ------- ----------
100-80=20 60-80=-20 ------- -------
100-100=0 -------- ------ -------

Sign in to comment.

 Accepted Answer

a = [2743.727 2743.727 2743.727 2743.727];
b = [2304.763 2304.763 2402.288 2304.764 2304.764];
c = a - b.'
c = 5×4
438.9640 438.9640 438.9640 438.9640 438.9640 438.9640 438.9640 438.9640 341.4390 341.4390 341.4390 341.4390 438.9630 438.9630 438.9630 438.9630 438.9630 438.9630 438.9630 438.9630

9 Comments

IF WE HAVE
A=
2743.727 2743.727 2743.727 2743.727
2714.443 2714.442 2714.441 2714.441
2704.226 2704.226 2704.227 2704.228
2699.598 2699.598 2699.597 2699.596
2696.508 2696.508 2696.506 2696.506
2694.07 2694.07 2694.069 2694.069
2692.179 2692.178 2692.174 2692.175
2690.622 2690.622 2690.622 2690.622
2689.384 2689.384 2689.383 2689.382
2688.354 2688.354 2688.349 2688.349 ]
AND
B=
2304.763 2304.763 2402.288 2304.764 2304.764
2305.205 2305.205 2402.773 2305.205 2305.205
2305.634 2305.636 2403.23 2305.636 2305.638
2306.094 2306.093 2403.719 2306.093 2306.091
2306.572 2306.571 2404.227 2306.571 2306.569
2307.055 2307.054 2404.746 2307.054 2307.053
2307.551 2307.545 2405.275 2307.545 2307.542
2308.03 2308.03 2405.789 2308.03 2308.03
2308.529 2308.527 2406.322 2308.527 2308.526
2309.031 2309.025 2406.857 2309.025 2309.021 }
HOW CAN CALCULATE C=A-B'
A MATRICS (ROW=3,COL=4),B (ROW=3,COL=5)
HOW CAN CALCULATE C=A-B'?
What size of result do you need? 3 x 4 x 5?
example:
a =
10 -30 -20 -10
50 10 20 30
>> b
b =
90 50 60 80 100
40 50 60 100 20
i want
c =
-80 -120 -110 -100
-40 -80 -70 -60
-50 -90 -80 -70
-70 -110 -100 -90
-90 -130 -120 -110
c =
10 -30 -20 -10
0 -40 -30 -20
-10 -50 -40 -30
-50 -90 -80 -70
30 -10 0 10
if a(n*m) and b(n*k)???? c=n*(m*k)
a = [
10 -30 -20 -10
50 10 20 30]
a = 2×4
10 -30 -20 -10 50 10 20 30
b = [
90 50 60 80 100
40 50 60 100 20]
b = 2×5
90 50 60 80 100 40 50 60 100 20
c = a - permute(b, [1 3 2])
c =
c(:,:,1) = -80 -120 -110 -100 10 -30 -20 -10 c(:,:,2) = -40 -80 -70 -60 0 -40 -30 -20 c(:,:,3) = -50 -90 -80 -70 -10 -50 -40 -30 c(:,:,4) = -70 -110 -100 -90 -50 -90 -80 -70 c(:,:,5) = -90 -130 -120 -110 30 -10 0 10
thank you very mach,but can you please ,get out as:(5*4*2)
i want
c =
-80 -120 -110 -100
-40 -80 -70 -60
-50 -90 -80 -70
-70 -110 -100 -90
-90 -130 -120 -110
c =
10 -30 -20 -10
0 -40 -30 -20
-10 -50 -40 -30
-50 -90 -80 -70
30 -10 0 10

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!