calculate differences inside columms between absolute and dinamic references inside of Matrix. Saving results.

1 view (last 30 days)
Dear friends, few days ago, I asked a question a litle bit similar than this one, but I made some changes and i need reply specially for this problem. In the other case I needed to re-arrange in advance the elements, now, I need to do the calculations shown below:
I have a matrix like this imput:
i mput:
306 305,952 304,683 302,265 300,219 (1)
306 306,008 304,977 302,45 299,846 (2)
306 305,962 304,84 302,413 299,812 (3)
306 306,051 305,051 302,396 299,877 (4)
306 306,003 304,891 302,163 300,017 (5)
306 306,004 305,002 301,997 300,186 (6)
406 406,016 404,943 402,467 400,224 (7)
406 406,009 404,961 402,483 400,361 (8)
406 406,014 404,852 402,547 400,287 (9)
406 406,043 404,99 402,52 400,372 (10)
406 406,048 405,105 402,425 400,817 (11)
406 406,034 404,928 402,425 400,623 (12)
506 506,038 505,182 502,518 500,878 (13)
506 506,003 505,208 502,728 500,684 (14)
506 505,971 505,11 502,841 501,118 (15)
506 505,979 505,083 502,644 500,922 (16)
506 505,985 505,065 502,942 500,955 (17)
506 506,062 505,067 502,818 501,28 (18)
I would like to calculate the differences between rows, this is, for example, all rows values minus the absoute one, but keeping order, I mean, create a new matrix with this differences. This, would be able with mxn matrix, not taking care about the size of this.
Such a example, in this link is the original file of imput
desired output --> out
100 100,064 100,26 100,202 100,005 (7)-(1)
100 100,001 99,984 100,033 100,515 (8)-(1)
100 100,052 100,012 100,134 100,475 (9)-(1)
100 99,992 99,939 100,124 100,495 (10)-(1)
100 100,045 100,214 100,262 100,8 (11)-(1)
100 100,03 99,926 100,428 100,437 (12)-(1)
200 200,086 200,499 200,253 200,659 (13)-(1)
200 199,995 200,231 200,278 200,838 (14)-(1)
200 200,009 200,27 200,428 201,306 (15)-(1)
200 199,928 200,032 200,248 201,045 (16)-(1)
200 199,982 200,174 200,779 200,938 (17)-(1)
200 200,058 200,065 200,821 201,094 (18)-(1)
Depending on the result I will obtain I will post a new question, related with this one but not directly connected with.
Best Regards , and heartfelt thanks.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 16 Sep 2013
Edited: Azzi Abdelmalek on 16 Sep 2013
A=[306 305.952 304.683 302.265 300.219
306 306.008 304.977 302.45 299.846
306 305.962 304.84 302.413 299.812
306 306.051 305.051 302.396 299.877
306 306.003 304.891 302.163 300.017
306 306.004 305.002 301.997 300.186
406 406.016 404.943 402.467 400.224
406 406.009 404.961 402.483 400.361
406 406.014 404.852 402.547 400.287
406 406.043 404.99 402.52 400.372
406 406.048 405.105 402.425 400.817
406 406.034 404.928 402.425 400.623
506 506.038 505.182 502.518 500.878
506 506.003 505.208 502.728 500.684
506 505.971 505.11 502.841 501.118
506 505.979 505.083 502.644 500.922
506 505.985 505.065 502.942 500.955
506 506.062 505.067 502.818 501.28 ]
out=bsxfun(@minus,A(7:end,:),A(1,:))
  1 Comment
Miguelcm90
Miguelcm90 on 17 Sep 2013
If i increase the number of rows with the same number in the first column,
out = bsxfun(@minus,x(7:end,:),x(1,:))
should be changed, right?, I need something which detects when the number of the first column is changing.
Thanks

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!