Displaying sum on plot
4 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a code that creates a plot, and on the plot, I need to display the total sum of the array that makes up the plot. I have the total sum, however, I am just unsure as to how I will display it on the plot using a function like fprintf? The value that is displayed needs to be able to be changed depending on whatever the sum may be.
Note: I cannot upload my code due to copyright reasons.
0 件のコメント
採用された回答
Paul
2022 年 10 月 22 日
Use text
rng(100)
x = rand(10,1); % some data
plot(x)
text(1,.1,"Sum = " + string(sum(x)))
Modify as needed
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2022 年 10 月 22 日
You can text() it into place. Or you could title()
t = "Sum of squares: " + TheSum;
title(t)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!