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

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

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!