num2str error in textbox
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mary Hemler
el 22 de Abr. de 2020
Comentada: Adam Danz
el 22 de Abr. de 2020
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?
0 comentarios
Respuesta aceptada
Adam Danz
el 22 de Abr. de 2020
Editada: Adam Danz
el 22 de Abr. de 2020
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!