Plotting mean across a graph
48 ビュー (過去 30 日間)
古いコメントを表示
Should be an easy question, but I'm having issues plotting a flat line across this 52x2 array, X being column 1 with datetime and Y being values from 0-100. The graph itself shows, but not the mean. I know that having 3 plot functions seems redundant but only the second one works and I dont know why
file='SearchesForFullMoon_Year.xlsx';
[X, Y]=readvars('SearchesForFullMoon_Year.xlsx');
Ymean=mean(Y,'all');
plot(X, Ymean,'r','LineWidth',1.5)
plot(X, Y, 'k','LineWidth',1.5)
hold on;
plot(Ymean, 'r','LineWidth',1.5)
0 件のコメント
回答 (2 件)
Star Strider
2020 年 11 月 17 日
Try this:
plot(xlim, [1 1]*Ymean, 'r','LineWidth',1.5)
The ‘Ymean’ value should be a constant, so it is necessary to plot it as a vector by multiplying it by [1 1].
Without your data to test this with, I am posting this as UNTESTED CODE. It should work.
0 件のコメント
Steven Lord
2020 年 11 月 17 日
If I understand what you want to do correctly, use the yline function.
x = datetime('today') + days(0:9);
y = 10*rand(size(x));
plot(x, y)
yline(mean(y))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
