saving in new folder by using saveas
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
HYZ
am 31 Aug. 2022
Beantwortet: Walter Roberson
am 31 Aug. 2022
hi, this is my code. I would like to save all images from saveas into polar plots folder which was created in the current directory.
Please help. thanks.
rho = [AUC_zeroA_avg AUC_zeroB_avg AUC_zeroC_avg AUC_zeroD_avg AUC_zeroE_avg AUC_zeroF_avg AUC_zeroG_avg AUC_zeroH_avg AUC_zeroA_avg];
rho = rho./max(rho,[],2);
for i = 1: size (OSI,1)
if OSI (i) > 0.5
theta = 0 : pi/4: 2*pi;
p (i) = figure (i);
polarplot (theta, rho (i,:));
pax = gca;
thetaticks(0:45:315)
pax.ThetaDir = 'clockwise';
pax.ThetaZeroLocation = 'right';
pax.RTickLabel = []; %remove rho values inside polar plot
hlines = findall(gcf,'Type','line'); set(hlines,'LineWidth',3); %inside lines thicker
rl = rlim; hold on
polarplot([0 pi], rl(2)*[1 1], 'k--'); %connecting 0 and 180
polarplot([3*pi/2 pi/2], rl(2)*[1 1], 'k--'); %connecting 90 and 270
polarplot(linspace(0, 2*pi, 61), rl(2)*ones(61,1), 'k-', 'LineWidth', 2) %making border thicker
grid off;
title (sprintf('ROI %d: OSI %0.2f DSI %0.2f', i, OSI(i), DSI (i)))
mkdir polar plots
saveas (p (i),strcat('ROI', '_', num2str(i), '_', 'OSI', '_', num2str (OSI(i)), 'DSI', '_', num2str (DSI(i)), '.jpeg'));
close all
end
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 31 Aug. 2022
outdir = 'polar plots';
if ~exist(outdir, 'dir'); mkdir(outdir); end
rho = [AUC_zeroA_avg AUC_zeroB_avg AUC_zeroC_avg AUC_zeroD_avg AUC_zeroE_avg AUC_zeroF_avg AUC_zeroG_avg AUC_zeroH_avg AUC_zeroA_avg];
rho = rho./max(rho,[],2);
for i = 1: size (OSI,1)
if OSI (i) > 0.5
theta = 0 : pi/4: 2*pi;
p(i) = figure (i);
polarplot(theta, rho(i,:));
pax = gca;
thetaticks(pax, 0:45:315)
pax.ThetaDir = 'clockwise';
pax.ThetaZeroLocation = 'right';
pax.RTickLabel = []; %remove rho values inside polar plot
hlines = findall(p(i),'Type','line'); set(hlines,'LineWidth',3); %inside lines thicker
rl = rlim(pax); hold(pax, 'on');
polarplot(pax, [0 pi], rl(2)*[1 1], 'k--'); %connecting 0 and 180
polarplot(pax, [3*pi/2 pi/2], rl(2)*[1 1], 'k--'); %connecting 90 and 270
polarplot(pax, linspace(0, 2*pi, 61), rl(2)*ones(61,1), 'k-', 'LineWidth', 2) %making border thicker
grid(pax, 'off');
title([ax, sprintf('ROI %d: OSI %0.2f DSI %0.2f', i, OSI(i), DSI (i)))
imgname = "ROI_" + i + "_OSI_" + OSI(i) + "DSI_" + DSI(i) + ".jpeg";
outfile = fullfile(outdir, imgname);
saveas(p(i), outfile);
delete(p(i));
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu View and Analyze Simulation Results 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!