如何在MATLAB中的.fig文件中修改某些x轴值? [英] How modify some x-axis values in a .fig file in MATLAB?

查看:539
本文介绍了如何在MATLAB中的.fig文件中修改某些x轴值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.fig文件,我只想在x轴上修改2个值.

I have a .fig file that i want to modify just 2 values in x-axis.

当我没有绘图的源代码时怎么办?只有一个.fig文件.

How is it possible when i do not have the source code of plotting? There is just a .fig file.

推荐答案

使用get(gca,...)提取数据可能是最直接的解决方案.但是,还有其他一些晦涩却有用的MATLAB功能值得一提.

Pulling the data out with get(gca,...) is probably the most direct solution. However, there is some other obscure but useful MATLAB functionality worth mentioning.

首先是MATLAB能够从图形生成M文件的功能,该功能可用于以编程方式重新创建和修改图形.只需单击以下菜单项,您将在编辑器中获得一个新功能,如function createfigure(X1, Y1),它将完全重新创建图形,但带有一些新数据X1Y1.

The first is the ability of MATLAB to generate M-files from figures, which can be used to recreate and modify a figure programmatically. Just click the following menu item and you will get a new function in the editor like function createfigure(X1, Y1) that will exactly recreate the figure, but with some new data X1 and Y1.

值得一提的另一件事是,.fig文件实际上是MAT文件,其中包含指定图形的数据.例如,以下命令会将.fig数据加载到MATLAB中的struct中,您可以轻松访问绘图数据:

The other thing worth mention is that .fig files are really MAT-files containing data specifying the figure. For instance, the following commands will load the .fig data into a struct in MATLAB and you can access the plot data easily:

>> f = load('testjunk.fig','-mat')
f = 
    hgS_070000: [1x1 struct]
>> axesNum = 1; seriesNum = 1;
>> series = f.hgS_070000.children(axesNum).children(seriesNum)
series = 
          type: 'graph2d.lineseries'
        handle: 172.0051
    properties: [1x1 struct]
      children: []
       special: []
>> X1 = series.properties.XData
ans =
    0.0305    0.7441    0.5000    0.4799    0.9047
>> Y1 = series.properties.YData
ans =
    0.6099    0.6177    0.8594    0.8055    0.5767

混合并匹配以完成工作.

Mix and match to get the job done.

这篇关于如何在MATLAB中的.fig文件中修改某些x轴值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆