我在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';
读取和写入文件夹。
有人可以帮我解决这个问题吗?
谢谢你们
答案 0 :(得分:1)
使用管理员权限打开MatLAB。
答案 1 :(得分:1)
一些建议:
要生成临时输出名称,请使用命令tempname
。
temp_name = tempname();
要连接路径和文件名,请使用fullfile
。
conrner_file = fullfile( '\', 'Temp', 'corners', [temp_name, '.in'] );
你应该注意不要混合'\ Temp'和'。\ Temp':因为第一个是绝对路径,而第二个是亲戚 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'];
现在有效吗?