필터 지우기
필터 지우기

saving in new folder by using saveas

조회 수: 5 (최근 30일)
HYZ
HYZ 2022년 8월 31일
답변: Walter Roberson 2022년 8월 31일
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

채택된 답변

Walter Roberson
Walter Roberson 2022년 8월 31일
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개)

카테고리

Help CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by