简体   繁体   中英

Predictive coding without using loops in Matlab?

I have a set of numbers and I want to use predictive coding to get smaller values for this set of data as each value should not differ to much from the last. I was just starting very simply with a expected value that each value would be the same as the last, and then just store the error.

For some simple data:

1 2 -3 1

The values I should get are

1 1 -5 4

The way I was doing this compression was one line, but to decompress I need the last value, so I put this in a loop. Is there a way to do this, and possibly more complex(looking at more the just the last value) predictive coding without needing to use Matlab loops.

As suggested by @Divakar, constructing the new values can be done by

B = [A(1) diff(A)];

Obtaining the original from this result, the inverse of the above procedure, is done through

A = cumsum(B);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM