Want to save in a selected folder

%% Is it possible to save (.m fig) all the Figures (say 10 numbers) in a selected folder (say, D:\PKP) after running the code
Fr = .1; M = .2; Kp = 0.50; lambda = 0.1; Nr = 0.1; Pr = 7; Rd = 0.5; Nb = 0.5; Nt = 0.5; H = 0.01;
Ec = 0.01; Le = 2; Sr = 1; D = 0.5; n = 1; E = 0.5; Bi = 0.5; Slip = 0.1; V = [0 3 5]/10; mx = []; my = [];
for M = V
for Kp = [0 0.5]
ODE = @(x,y)[ y(2); y(3); - y(1)*y(3) + (1+Fr)*y(2)^2 + (M+Kp)*y(2) - lambda*( y(4) - Nr*y(6) );
y(5); -(Pr/(1+Rd))*( y(1)*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + H*y(4) + Ec*y(3)^2 );
y(7); -Pr*Le*y(1)*y(7) - (Nt/Nb)*(-(Pr/(1+Rd))*(y(1)*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + H*y(4) + Ec*y(3)^2)) + Le*Pr*Sr*(1 + D*y(4))^n *y(6)*exp(-E/(1 + D*y(4)))];
BC = @(ya,yb)[ya(1); ya(2)-1-Slip*ya(3); ya(5)+Bi*(1-ya(4)); ya(7)+(Nt/Nb)*ya(5); yb([2;4;6])]; xa = 0; xb = 6; x = linspace(xa,xb,101);
solinit = bvpinit(x,[0 1 0 1 0 1 0]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,x);
figure(1);plot(x,S(2,:),'-','LineWidth',2); hold on,
end
end

 Accepted Answer

Dyuman Joshi
Dyuman Joshi on 29 Nov 2023
Use exportgraphics or print and specify the full path with the filename.

11 Comments

Dear Dyuman
I want to save .m figures in (D:\PKP) not png/jpg, help please
There are no .m figures.
Did you mean .fig?
Dyuman Joshi
Dyuman Joshi on 29 Nov 2023
Edited: Dyuman Joshi on 29 Nov 2023
In that case, use savefig.
Can you create that with (D:\PKP)
In that folder there are so many other .fig files are present.
Yes, here's an example -
%Change the current directory to D:\PKP
cd D:\PKP
%Draw a figure
h = figure;
fplot(@sin)
%Save the figure
savefig(h, 'sin_curve.fig')
Thank you very much Dyuman, that worked.
You are welcome!
Dear Dyuman
Could you put some ideas in the following link:
https://in.mathworks.com/matlabcentral/answers/2052542-import-and-export-of-excel-sheet-work?s_tid=mlc_ans_email_view
Minati, I have to take care of something first. After that, I'll surely take a look at that question.

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!