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

filename = 'test.mat';
save(filename);
これでワークスペースを現在開いているフォルダにtest.matとして保存することができますが、別のフォルダに保存するとしたらどうすればいいですか?
よろしくお願いいたします。

 Réponse acceptée

Hernia Baby
Hernia Baby le 1 Juil 2021
Modifié(e) : Hernia Baby le 1 Juil 2021

3 votes

パスを通してあげればOKです。
save時に fullfile でフルパス指定してください。
毎度、任意にパスを決めたい場合は uigetdir をおすすめします。
以下サンプルコード
clear,clc;
x=1+2;
filename = 'test.mat';
pass = uigetdir;
save(fullfile(pass,filename),'-regexp','x');

3 commentaires

NO MIYA
NO MIYA le 3 Juil 2021
丁寧な回答ありがとうございます!
関連を調べていったところuisaveも使えそうですね。
Hernia Baby
Hernia Baby le 4 Juil 2021
@NO MIYA さん
uisaveもシンプルでいいですね!
自分の場合は先にカレントディレクトリを決めて、import~exportまでするので今回の形にしてます。
このやり方は繰り返し出力させるときに便利ですので、ご参考に。
NO MIYA
NO MIYA le 12 Juil 2021
なるほど。繰り返しまで考えていませんでした。
ありがとうございます。目から鱗が落ちた気分です。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 環境と設定 dans Centre d'aide et File Exchange

Produits

Version

R2020a

Community Treasure Hunt

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

Start Hunting!