Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 在文本框周围有紧密的边框_Matlab_Matlab Figure - Fatal编程技术网

Matlab 在文本框周围有紧密的边框

Matlab 在文本框周围有紧密的边框,matlab,matlab-figure,Matlab,Matlab Figure,我想在matlab图形中显示矩阵D。这是代码: figure; text('HorizontalAlignment' , 'center' ,... 'string' , num2str(D) ,... 'FontSize' , 20 ,... 'BackgroundColor' , 'w'); axis off 如何去除灰色边界?以下是一种基于找到的答案的方法 诀窍是使用textbox注释对象并设置其位置,使

我想在matlab图形中显示矩阵D。这是代码:

figure;
text('HorizontalAlignment'  , 'center'  ,...
'string'               , num2str(D)   ,...
'FontSize'             , 20       ,...
'BackgroundColor'      , 'w');  axis off

如何去除灰色边界?

以下是一种基于找到的答案的方法

诀窍是使用textbox注释对象并设置其位置,使其填充使用标准化单位创建的图形

下面是我稍加修改的代码:

clear
clc
close all

D = magic(5);

hText = annotation('textbox','Position',[.2 .8 .2 .2], 'FitBoxToText','on','String',num2str(D),'HorizontalAlignment'  , 'center'  ,...
'string'               , num2str(D)   ,...
'FontSize'             , 20       ,...
'BackgroundColor'      , 'w'); 

set(hText,'Units','pixels'); 

Text_Pos = get(hText,'Position');

fPos = get(gcf,'Position'); 
fPos(3:4)=Text_Pos(3:4) 

set(gcf,'Position',fPos)
set(hText,'Units','norm','Position',[0 0 1 1])
以及输出的屏幕截图:

希望有帮助

我怎样才能摆脱灰色的边界

设置人物背景以匹配文本框的颜色

figure('color','w');

那么@seda你试过我的建议了吗?是的,我试过了。非常感谢。但是文本框没有完全显示出来。因此需要调整大小,这令人沮丧。我想textbox不适合我尝试做的事情。更干净的解决方案是创建latex表代码,因为我要将textbox嵌入latex文档中@贝诺伊图11