【问题标题】:Cannot open file for output (Matlab)无法打开文件进行输出(Matlab)
【发布时间】:2013-02-01 22:21:10
【问题描述】:

我在matlab中遇到问题,问题描述如下:

当我尝试读取图像(我有几张图像)并将它们写入特定文件夹时,matlab 会触发错误提示

  Error using ==> imwrite at 394
Can't open file "\Temp\\inim735282.4716703009300000.jpg" for writing.
You may not have write permission.

我可以知道为什么会这样吗?

这是出现问题的代码

mkdir('.\Temp');
temp_name =  sprintf('%.16f',now);
corner_file = ['\Temp\corners', temp_name,'.in'];
image_file = ['\Temp\inim', temp_name,'.jpg'];
out_file = ['\Temp\out', temp_name,'.desc'];
out_imname = ['\Temp\out', temp_name,'.desc.jpg'];

我试图通过省略来更改它

mkdir('.\Temp');

此外,我通过这样做将文件夹中的路径指向文件夹

binary_path = 'C:\Users\cool\Documents\MATLAB\Experment\experiments\bag_of_words\Temp';

读写文件夹。

有人可以帮我解决这个问题吗?

谢谢大家

【问题讨论】:

    标签: image file matlab permissions binary


    【解决方案1】:

    以管理员权限打开 MatLAB。

    【讨论】:

    • 它不起作用,它尝试过,但它给了我一个错误,提示“未定义函数或方法 'do_all' 用于类型 'char' 的输入参数。”但是当它没有管理员权限时,它会一直运行,直到触发上述错误。命令行是“ do_all('config_file_1')
    • 是你用的插件吗?如果是插件,是不是忘记添加路径了?
    【解决方案2】:

    一些建议:

    1. 要生成临时输出名称,请使用命令tempname

      temp_name = tempname();
      
    2. 要连接路径和文件名,请使用fullfile

      conrner_file = fullfile( '\', 'Temp', 'corners', [temp_name, '.in'] );
      
    3. 您应该注意不要将 '\Temp' 和 '.\Temp' 混用:因为第一个是绝对路径,而第二个是相对 strong> cwd 的路径。

    编辑: 怎么样:

    temp_name = tempname(); % temp name + folder name in TEMP
    corner_file = [ temp_name,'.in'];
    image_file = [ temp_name,'.jpg'];
    out_file = [temp_name,'.desc'];
    out_imname = [temp_name,'.desc.jpg'];
    

    现在可以用了吗?

    【讨论】:

    • Shai,我所做的更改并没有什么好处。这可能是因为windwos 7 安全属性。
    • unrecognized suffix ".jpg" 错误消失了,但另一个错误来了,即 "unrecognized suffix ".jpg" 这是什么意思?
    • Shai,它确实可以完美运行,但是输出不是预期的。它给出了一个温暖的说法,即“无法打开文件”。无论如何谢谢你
    猜你喜欢
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 2021-03-31
    • 1970-01-01
    相关资源
    最近更新 更多