필터 지우기
필터 지우기

Displaying sum on plot

조회 수: 2 (최근 30일)
Bozza
Bozza 2022년 10월 22일
답변: Paul 2022년 10월 22일
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.

채택된 답변

Paul
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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 10월 22일
You can text() it into place. Or you could title()
t = "Sum of squares: " + TheSum;
title(t)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by