I want to save my figure in another path. Every time I used the command save figure it saved in Desktop how I can change it
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew Worker
am 26 Mai 2021
Bearbeitet: Rena Berman
am 16 Dez. 2021
clc;
clear;
N = [10 20 30 40 50];
M = [1 2 3 4 5];
K=[1 3 5 6 7];
x = linspace(0, 1, 17);
legendString = "N = " + string(N) + ", M = " + string(M);
ph = plot(x,N.*x');
hold on
ph2 = plot(x+2,N.*x');
legend(ph,legendString)
savefig('FA.fig')
1 Kommentar
Akzeptierte Antwort
Allen
am 26 Mai 2021
If your filename does not indicate the filepath in front of the filename, then MATLAB used your default directory location to save files. You can correct this by adding the desired file path to your filename.
file = 'C:\...\FA.fig';
%or
file = fullfile('C:\...','FA.fig');
If you are wanting more flexibility of where to save your files, you can use the uiputfile function to designate a directory location and filename before saving your file.
% Launches a system save file window.
[fn,pn] = uiputfile("*.fig","Save Figure to Specified Location");
% Performs a quick check to make sure that the save file window was not
% closed with X or Cancel.
if ~isnumeric(fn) % fn will be numeric if no file is selected, else it will be text.
savefig(fullfile(pn,fn))
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!