当前位置:网站首页>MATLAB如何修改默认设置
MATLAB如何修改默认设置
2022-07-03 06:17:00 【最爱大盘鸡】
今天在github上下载了一个代码,运行结束之后,发现它把我的figure里面的默认解释器改了。
原本的设置是:
interpreter = 'none'
但我打开figure的属性窗口一看,这个属性被改成了
interpreter = 'Latex'
这样在画图过程中,一旦文本里面有汉字,就会出现下面的警告:
警告: 更新 Text 时出错。 字符串标量或字符向量必须具备有效的解释器语法
解决方法有2个:
- 是以后每次写
legend()或者xlabel()、ylabel()的时候加上interpreter = 'none' - 把默认设置修改回原来的样子
我决定一劳永逸,选择第二个。
开始上网查资料,找到了这篇文章,介绍了如何把figure的背景色换成白色,代码是set(0,'defaultfigurecolor','w')。我从这篇文章中受到启发,认为可以找到默认设置的句柄,再通过set()设置句柄参数,恢复默认设置。多说一嘴,代码里面0这个句柄代表的是计算机屏幕(可以参考这里)。
下一步是上网查找MATLAB的默认句柄有什么,找到了这篇文章。
作者说可以用get(0,'factory')来获取默认的属性定义值。在MATLAB命令行里面输入这行命令之后,出现了好多好多可以设置的属性。但我找了一下,没有发现interpreter的名字,感觉可能不是用这行代码来做。
当下心思一动,心想可以不可以把factory替换成default,在命令行输入代码get(0,'default'),得到如下输出:
ans =
包含以下字段的 struct:
defaultFigurePosition: [680 558 560 420]
defaultFigurePaperPositionMode: 'auto'
defaultFigurePaperType: 'A4'
defaultFigurePaperUnits: 'centimeters'
defaultFigurePaperSize: [21 29.7000]
defaultTextInterpreter: 'latex'
defaultLegendInterpreter: 'latex'
defaultAxesTickLabelInterpreter: 'latex'
注意到最后三行出现了interpreter和latex的名字, 这就是要找的默认设置。
在命令行输入下面三行代码就可以把解释器换成MATLAB的默认设置了。
set(0,'defaultTextInterpreter','none');
set(0,'defaultLegendInterpreter','none');
set(0,'defaultAxesTickLabelInterpreter','none');
再次输入get(0,'default')检查一下是否设置成功,得到如下输出。
ans =
包含以下字段的 struct:
defaultFigurePosition: [680 558 560 420]
defaultFigurePaperPositionMode: 'auto'
defaultFigurePaperType: 'A4'
defaultFigurePaperUnits: 'centimeters'
defaultFigurePaperSize: [21 29.7000]
defaultTextInterpreter: 'none'
defaultLegendInterpreter: 'none'
defaultAxesTickLabelInterpreter: 'none'
成功!这下在figure中画图用汉字的时候再也不会给警告了。
通过这件事情我觉得吧,还是得多思考多想一想怎么解决问题,解决问题后还要及时记录,防止自己忘记。
边栏推荐
- Characteristics and isolation level of database
- .NET程序配置文件操作(ini,cfg,config)
- Page text acquisition
- BeanDefinitionRegistryPostProcessor
- What's the difference between using the Service Worker Cache API and regular browser cache?
- Cesium 点击获三维坐标(经纬度高程)
- ODL framework project construction trial -demo
- Apifix installation
- 堆排序和优先队列
- Migrate data from Amazon aurora to tidb
猜你喜欢

Kubernetes notes (VI) kubernetes storage

有意思的鼠标指针交互探究

Detailed explanation of contextclassloader

In depth analysis of kubernetes controller runtime

Oauth2.0 - use database to store client information and authorization code

Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster

. Net program configuration file operation (INI, CFG, config)

arcgis创建postgre企业级数据库

Kubesphere - build Nacos cluster

Alibaba cloud OOS file upload
随机推荐
Oauth2.0 - Introduction and use and explanation of authorization code mode
堆排序和优先队列
Cesium 点击获三维坐标(经纬度高程)
Support vector machine for machine learning
Various usages of MySQL backup database to create table select and how many days are left
.NET程序配置文件操作(ini,cfg,config)
Request weather interface format, automation
Use abp Zero builds a third-party login module (I): Principles
Analysis of Clickhouse mergetree principle
arcgis创建postgre企业级数据库
Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
Mysql5.7 group by error
Kubernetes notes (VIII) kubernetes security
Zhiniu stock project -- 04
phpstudy设置项目可以由局域网的其他电脑可以访问
Kubernetes notes (III) controller
Use @data in Lombok to simplify entity class code
Zhiniu stock project -- 05
Une exploration intéressante de l'interaction souris - pointeur
Zhiniu stock -- 03