简体   繁体   English

如何写入.mat文件matlab

[英]how to write to .mat file matlab

I have a couple of .mat files in my folder. 我的文件夹中有几个.mat文件。 I want to write to each of them a couple of variables, strings, specified by myself during execution of this program. 我想给他们每个人写一些变量,字符串,在我执行这个程序时由我自己指定。 How can I write from matlab and save these strings to .mat ? 如何从matlab编写并将这些字符串保存到.mat?

You can use the command save with "-append" parameter 您可以使用命令save with“-append”参数

save matfile -append 保存matfile -append

Check the details at http://www.mathworks.com/help/techdoc/matlab_prog/f10-61206.html 请访问http://www.mathworks.com/help/techdoc/matlab_prog/f10-61206.html查看详细信息

http://www.mathworks.com/help/techdoc/import_export/braidzi-1.html http://www.mathworks.com/help/techdoc/import_export/braidzi-1.html

save('mymatfile.mat', 'string1', 'variable42');

Unless your question wasn't stated clearly, I don't think you searched very hard for an answer before asking. 除非你的问题没有明确说明,否则我认为你在问之前并没有非常努力地寻找答案。

You can append the .mat files using the -append flag when saving. 保存时,可以使用-append标志附加.mat文件。 If the variable name you are trying to append to the file already exists in the file, it will overwritten with this command. 如果您尝试附加到文件的变量名已经存在于该文件中,则该命令将覆盖该变量名。

Ex. 防爆。

>> save <your .mat filename> <your variables> -append

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM