声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1059|回复: 6

[编程技巧] 请教一个有关save的问题

[复制链接]
发表于 2010-11-26 20:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
save 命令可以将某些变量除去然后保存吗?有一个程序需要在运行的时候保存所有变量到一个mat文件,但现在这个程序里添加了200多个OPC items, 因为在保存的时候这些OPC没有用,而且很费资源,会直接卡死。请问有没有什么方法只保存除OPC以外的所有变量啊?OPC的变量都满足 *_opc的形式
回复
分享到:

使用道具 举报

发表于 2010-11-26 21:15 | 显示全部楼层
本帖最后由 hustxyong 于 2010-11-26 21:15 编辑

save 命令可以选择Workspace中要保存的变量,但是你的程序需要在运行的时候保存所有变量到一个mat文件,试试在调用save之前用clear命令把不需要的变量清除掉
发表于 2010-11-26 21:32 | 显示全部楼层
本帖最后由 zhouyang664 于 2010-11-26 21:42 编辑

回复 2 # hustxyong 的帖子

可是运行clear,程序就没法往下运行了!
好像不太好实现...
发表于 2010-11-27 14:51 | 显示全部楼层
帮助文件里面写的很清楚,可以选择性的保存
  1. Saving Selected Variables

  2. To save selected variables from the workspace, list the variables in the call to the save function. For example, if the current workspace contains variables A through Z, save B and C to bc.mat as follows:

  3. save('bc.mat', 'B', 'C')

  4. To save variables with names that match a pattern, use one of the following options:

  5.     *

  6.       Include the wildcard character (*). For example, save all variables that start with str to a file named strinfo.mat:

  7.       save('strinfo.mat', 'str*')

  8.     *

  9.       Apply the -regexp option, which matches variables to regular expressions. For example, save all variables that start with Mon, Tue, or Wed to a file named myfile.mat:

  10.       save('myfile.mat', '-regexp', '^Mon|^Tue|^Wed')

  11.       For more information, see Regular Expressions in the MATLAB Programming Fundamentals documentation.
复制代码

评分

1

查看全部评分

发表于 2010-11-27 16:54 | 显示全部楼层
回复 4 # qibbxxt 的帖子

这样就好整了,但如果想保存的变量很多,而且都是没有规律的命名,该怎么操作呢?
发表于 2010-11-28 00:24 | 显示全部楼层
发表于 2010-11-28 12:48 | 显示全部楼层

clear 也是可以选择性的清除的,要存的变量多于要清除的变量就先把要清除的去掉,否则就直接save相关变量

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 18:40 , Processed in 0.060175 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表