Plotting streaming data at unequal intervals

I am trying to plot a data that is streamed. It is saved in my logger only when particular value is changed.
For example:
loggedData = [1 NaN NaN 2 NaN NaN NaN 10 NaN NaN NaN];
actualData = [1 1 1 2 2 2 2 10 10 10 10];
time = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10];
plot(time, loggedData)
plot(time, actualData)
I would like to plot(time, loggedData) but it would not work similar to plot(time, actualData). Changing from loggedData to actualData would increase the storage unnecessarily but only option I know as of now.
If I do a scatter plot, it would not connect with lines inbetween as I wanted.
Is there any solution?

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 19 日
編集済み: Ameer Hamza 2020 年 5 月 19 日

0 投票

loggedData = [1 NaN NaN 2 NaN NaN NaN 10 NaN NaN NaN];
time = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10];
plot(time, fillmissing(loggedData, 'previous'))

2 件のコメント

Kumaraguru Sivasankaran
Kumaraguru Sivasankaran 2020 年 5 月 20 日
Thanks. It works.
Ameer Hamza
Ameer Hamza 2020 年 5 月 20 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by