imwrite を使用してデータをフ​ァイルに書き込もうと​するとエラーが発生す​るのはなぜですか?

imwrite 関数を使用してデータをファイルに書き込もうとしています。その際、その時点で存在しないフォルダー内のファイルへのパスを作成し、保存しようとしています:

Z = peaks; surf(Z)
axis tight
set(gca,'nextplot','replacechildren');
surf(sin(2*pi/20)*Z,Z);
F = getframe;
imwrite(F.cdata,'newFolder/testfile.jpeg','jpg')

実行すると次のエラーが発生します:

次を使用中のエラー:ファイル "newFolder/testfile.jpeg" を開いて書き込むことができません。書き込み権限がない可能性があります。

 Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 8 de Ag. de 2024

0 votos

imwrite では存在しないフォルダ内のファイルへの書き込みはできません。事前にディレクトリを作成するには mkdir コマンドを使用します。
mkdir('newFolder') 
imwrite(F.cdata,'newFolder/testfile.jpeg','jpg')

Más respuestas (0)

Categorías

Más información sobre Instrument Control Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2009a

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!