saveで任意のディ​レクトリに保存するに​はどうすればいいです​か?

131 views (last 30 days)
NO MIYA
NO MIYA on 1 Jul 2021
Commented: NO MIYA on 12 Jul 2021
filename = 'test.mat';
save(filename);
これでワークスペースを現在開いているフォルダにtest.matとして保存することができますが、別のフォルダに保存するとしたらどうすればいいですか?
よろしくお願いいたします。

Accepted Answer

Hernia Baby
Hernia Baby on 1 Jul 2021
Edited: Hernia Baby on 1 Jul 2021
パスを通してあげればOKです。
save時に fullfile でフルパス指定してください。
毎度、任意にパスを決めたい場合は uigetdir をおすすめします。
以下サンプルコード
clear,clc;
x=1+2;
filename = 'test.mat';
pass = uigetdir;
save(fullfile(pass,filename),'-regexp','x');
  3 Comments
Hernia Baby
Hernia Baby on 4 Jul 2021
@NO MIYA さん
uisaveもシンプルでいいですね!
自分の場合は先にカレントディレクトリを決めて、import~exportまでするので今回の形にしてます。
このやり方は繰り返し出力させるときに便利ですので、ご参考に。
NO MIYA
NO MIYA on 12 Jul 2021
なるほど。繰り返しまで考えていませんでした。
ありがとうございます。目から鱗が落ちた気分です。

Sign in to comment.

More Answers (0)

Categories

Find more on 環境と設定 in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!