data storage, reduce the repeated elements, recurrence

if input is:
a = [5 5 1 6 6 6 4 4 2]
how to get the output as:
elements: [5 1 6 4 2]
recurrence: [2 1 3 2 1]

 採用された回答

Stephen23
Stephen23 2017 年 8 月 25 日
編集済み: Stephen23 2017 年 8 月 25 日

0 投票

3 件のコメント

hamed amini
hamed amini 2017 年 8 月 25 日
Not sure if I am doing something wrong, but RunLength looks for RunLength.c which is not there.
------------------------------------------------
Ok = InstallMex('RunLength.c', 'uTest_RunLength');
------------------------------------------------
RLE worked perfectly:
https://uk.mathworks.com/matlabcentral/fileexchange/31123-rle-run-length-encoding
Adam
Adam 2017 年 8 月 25 日
RunLength.c is definitely included in the download zip
Jan
Jan 2017 年 8 月 25 日
@hamed: Click on the "Download" button on the top right to obtain the zip file, which contains the required C file. You need a C compiler to convert the C file to a mex function. Alternatively you can use the slower RunLength_M version.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDownloads についてさらに検索

製品

質問済み:

2017 年 8 月 25 日

コメント済み:

Jan
2017 年 8 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by