How can I plot 2 vectors of different length?
57 ビュー (過去 30 日間)
古いコメントを表示
Jonathan Bijman
2019 年 6 月 12 日
コメント済み: Michael Mauersberger
2020 年 4 月 29 日
Hello everyone
It could be the question sounds stupid, but I have 32 data (which correspond to averages of 9 measurements) and I want to plot along aprox 50 days
(Because there weren´t measurements some days)
Anyone has an idea of how can I do that? I was thinking by scatter, but appears the same error (different lenghts)
Thank u
0 件のコメント
採用された回答
Star Strider
2019 年 6 月 12 日
Without knowing any constraints you may have, try this:
data = rand(1, 32); % Create Data Vector
x = linspace(0, 50, numel(data)); % Create Independent Variable Vector
figure
plot(x, data)
If your data were calculated with respect to specific days, use a vector of those days as ‘x’. So long as there are exactly 32 of them, you can easily plot them.
5 件のコメント
Michael Mauersberger
2020 年 4 月 29 日
If you assume unequally distributed data, consider my answer to th quite similar question:
その他の回答 (1 件)
Walter Roberson
2019 年 6 月 12 日
You know which days had valid measurements. Pass the time coordinate corresponding to those days as the "x" coordinate to plot, if you want a line plot that draws between the missing data.
stem() plot might make sense in some cases.
It is possible to draw in segments. For that purpose, pass in nan as the y coordinates for the missing measurements, and be sure to include a marker type. You want the marker because you might have patterns such as NaN Point NaN and plot() will only draw a line when there are at least two finite points in a row.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!