Hi,
Based on the description, I understand that you are trying to create a rectangular solid border around a label object, which can be associated to a ‘uifigure’ in MATLAB or a block label in Simulink. You can refer to the code given below for each case mentioned earlier:
- Simulink Labels: To draw a rectangle border around a label in a Simulink model, you can add an annotation with the shape of a rectangle programmatically, by adding drop shadow and using “get_params” function to specify the annotation position beneath the respective block.
blockName = “block_name”;
blockPosition = get_param([gcs '/blockName], 'Position');
annotation = Simulink.Annotation([gcs], 'Your Label Text');
annotation.DropShadow = 'on';
rectLeft = blockPosition(1);
rectTop = blockPosition(2) + padding;
rectRight = blockPosition(3);
rectBottom = blockPosition(4);
annotation.Position = [rectLeft rectTop rectRight rectBottom]
- UI Labels: To create an axis label as an annotation with a solid border, you can use “annotation” function to specify annotation layout, color and text:
str = 'Straight Line Plot from 1 to 10';
anno = annotation('textbox',dim,'String',str, 'FitBoxToText','on');
For more information regarding usage of annotation objects in MATLAB & Simulink, refer to the documentation links mentioned below: