Hello! I am very new to matlab and am trying to put a text box in a plot with the value of a variable. The variable is located in a cell array. This is my code:
figure
polarplot(FR{4})
annotation('textbox','String','Mutual Info =',num2str(mutualInfoTotal{4}))
But I am getting an error message that says "Error using matlab.graphics.shape.TextBox. Invalid parameter/value pair arguments."
If I want to create a plot with a textbox in it that says 'Mutual Info =,' then call the mutual info value of a variable, what would be the correct code?

 채택된 답변

Adam Danz
Adam Danz 2020년 4월 22일
편집: Adam Danz 2020년 4월 22일

0 개 추천

Try
annotation('textbox','String',['Mutual Info =',num2str(mutualInfoTotal{4})])
or
annotation('textbox','String',sprintf('Mutual Info = %s',num2str(mutualInfoTotal{4})))
or if mutualInfoTotal{4} is a single, scalar value,
annotation('textbox','String',sprintf('Mutual Info = %d',mutualInfoTotal{4})) % for integer
% or
annotation('textbox','String',sprintf('Mutual Info = %.3f',mutualInfoTotal{4})) % for 3 dp

댓글 수: 2

Mary Hemler
Mary Hemler 2020년 4월 22일
Great, thanks! The first one worked. Follow-up question: right now, the textbox is placed in the middle of the polarplot. How can I put it on the outside of the plot?
Adam Danz
Adam Danz 2020년 4월 22일
See the syntax, annotation(lineType,x,y) where x and y are the location & size of the annotaiton object.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2020년 4월 22일

댓글:

2020년 4월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by