Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.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 当文件名包含Unicode字符时使用saveas保存地物_Matlab_Unicode_Save_Filenames_Matlab Figure - Fatal编程技术网

Matlab 当文件名包含Unicode字符时使用saveas保存地物

Matlab 当文件名包含Unicode字符时使用saveas保存地物,matlab,unicode,save,filenames,matlab-figure,Matlab,Unicode,Save,Filenames,Matlab Figure,总结: 我想保存一个文件名为σ=0.25.fig的图形,但保存失败 阐述: 我正在Win10上使用R2019b Update 3,我无法修改我的MATLAB配置以允许保存带有Unicode字符的.m文件,即功能“DefaultCharacterSet”卡在“US-ASCII”上,我被迫使用sprintf在源文件中存储各种非ASCII符号。这通常效果很好,但显然在尝试使用saveas时会出现问题 例如: 考虑下面的代码, hF=数字; saveas hF,sprintf'\x03C3=%4.2f.

总结: 我想保存一个文件名为σ=0.25.fig的图形,但保存失败

阐述: 我正在Win10上使用R2019b Update 3,我无法修改我的MATLAB配置以允许保存带有Unicode字符的.m文件,即功能“DefaultCharacterSet”卡在“US-ASCII”上,我被迫使用sprintf在源文件中存储各种非ASCII符号。这通常效果很好,但显然在尝试使用saveas时会出现问题

例如: 考虑下面的代码,

hF=数字; saveas hF,sprintf'\x03C3=%4.2f.fig',0.25%sprintf正确解析为σ=0.25.fig 在我的系统上是哪个?导致以下错误:

使用save时出错 无法写入MAT文件σ=0.25。图。 文件可能已损坏。 matlab.graphics.internal.figfile.figfile/写入行32中出错 saveobj.Path,obj.MatVersion,'-struct',SaveVars'; savefig第83行出错 FF.write; saveasfig第6行出错 savefigh,name; saveas第153行出错 feval['saveas'格式],h,name 问题: 鉴于上述错误,如何使用所需的文件名保存图形?

幸运的是,用于移动或重命名文件的函数不会遇到Unicode路径的相同问题。因此,我们只需将保存分为两个步骤,首先使用由saveas like字符组成的临时路径/名称,然后将其移动/重命名为所需的名称/路径:

saveashF,‘tmp.fig’; movefile'tmp.fig',fullfilepwd,sprintf'\x03C3=%4.2f.fig',0.25; 。。。产生预期的结果