필터 지우기
필터 지우기

How to save the output in a certain folder?

조회 수: 551 (최근 30일)
ck
ck 2016년 6월 26일
이동: Stephen23 2022년 9월 3일
How can I save a certain output in a specified folder? What function can I use for this?
Thank you.

채택된 답변

Chad Greene
Chad Greene 2016년 6월 26일
To save the variables x and y to a file called "myfile.mat" in a folder called "myfolder" try this:
x = 1:360;
y = sind(x);
save('myfolder/myfile.mat','x','y')
If the folder is not a subfolder of your current directory, you can specify the full filepath to that folder instead of "myfolder/..."

추가 답변 (1개)

Sarmed Wahab
Sarmed Wahab 2022년 9월 3일
이동: Stephen23 2022년 9월 3일
I am posting this for people finding relative answer.
for i = 1:5
x = rand(10,1) ;
y = 3*x + i^2 ;
plot(x,y,"bo"); hold on;
a = plot(x,y) ; hold off;
dest_dir = "C:\folder\PROJECT DATA\figure" + i ;
mkdir(dest_dir);
filename = "plot"+string(i)+".png";
% saveas(fig,filename)
fig_file = fullfile(dest_dir , filename)
%saveas(a, filename) %save the file there directory
saveas( a, fig_file)
result = "results"+i;
matfile = fullfile(dest_dir, result);
save(matfile);
%save(result)
end

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by