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

21 次查看(过去 30 天)
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')

采纳的回答

Allen
Allen 2021-5-26
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 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by