how can i export graph figures to excel?

1 visualizzazione (ultimi 30 giorni)
Ana Soph
Ana Soph il 19 Gen 2020
Commentato: Star Strider il 19 Gen 2020
Hello y'all, i have a question, How can I export figures plotted in Matlab to Excel?
i have this code:
clear;clc;
Cyears = 8;
Cdays = 31; % enero
% RAS: es mejor que cada año sea una columna
TMED = nan(Cdays, Cyears); % Average daily data: dia x año
TMAX = nan(Cdays, Cyears); % Max daily data: dia x año
TMIN = nan(Cdays, Cyears); % Min daily data: dia x año
for i=1:Cyears % cada año es una pestaña en la hoja de calculo
TS = xlsread('TEN',i); % archivo local a la carpeta
Tmed = mean(TS);
Tmax = max(TS);
Tmin = min(TS);
%ps=sort(p); % RAS: No need to sort
TMED(:, i)=Tmed'; % RAS: Mejor usar nombres que identifiquen el contenido, no nombres genericos como "A", "aux", etc.
TMAX(:, i)=Tmax'; % RAS: Mejor usar nombres que identifiquen el contenido, no nombres genericos como "A", "aux", etc.
TMIN(:, i)=Tmin'; % RAS: Mejor usar nombres que identifiquen el contenido, no nombres genericos como "A", "aux", etc.
end
% RAS: check (siempre chequear que las cosas intermedias tienen sentido)
figure(1); imagesc(TMED); colorbar;
figure(2); imagesc(TMAX); colorbar;
figure(3); imagesc(TMIN); colorbar;
% VECTORES PARA LAS CDFS
TMED_TS = TMED(:); %Promedio de las 8 hojas, 248 datos 31*8
TMAX_TS = TMAX(:); %valores maximos de cada dia, 248 datos
TMIN_TS = TMIN(:); %valores mínimos de cada dia 248 datos
xcdf_tmed = (floor(min(TMED_TS)):1:ceil(max(TMED_TS)))';% RAS: mejor un vector fijo para todas las CDFs de temperatura media
xcdf_tmax = (floor(min(TMAX_TS)):1:ceil(max(TMAX_TS)))';% RAS: mejor un vector fijo para todas las CDFs de temperatura
xcdf_tmin = (floor(min(TMIN_TS)):1:ceil(max(TMIN_TS)))';% RAS: mejor un vector fijo para todas las CDFs de temperatura
Ccdf_tmed = length(xcdf_tmed);
Ccdf_tmax = length(xcdf_tmax);
Ccdf_tmin = length(xcdf_tmin);
% La idea sería definir un xcdf distinto para TMED, TMAX y TMIN
% CDF LONG-TERM
CDFmed_lt = zeros(Ccdf_tmed, 1);
CDFmax_lt = zeros(Ccdf_tmax, 1);
CDFmin_lt = zeros(Ccdf_tmin, 1);
N_lt = length(TMED_TS);
for k=(1:N_lt)
CDFmed_lt = CDFmed_lt + (xcdf_tmed>=TMED_TS(k));
CDFmax_lt = CDFmax_lt + (xcdf_tmax>=TMAX_TS(k));
CDFmin_lt = CDFmin_lt + (xcdf_tmin>=TMIN_TS(k));
end
CDFmed_lt = CDFmed_lt/N_lt;
CDFmax_lt = CDFmax_lt/N_lt;
CDFmin_lt = CDFmin_lt/N_lt;
figure(4)
plot(xcdf_tmed, CDFmed_lt, '.-g'); hold on;
plot(xcdf_tmax, CDFmax_lt, '.-r');
plot(xcdf_tmin, CDFmin_lt, '.-b'); hold off;
title('CDFs de Largo Plazo');
legend('Temperatura media', 'Temperatura maxima', 'Temperatura minima')
xlabel('Temperatura (°C)');
ylabel('CDF');
% Create some arbitrary graphics
f1 = figure; f2 = figure;
% Connect to Excel, make it visible and add a worksheet
xl = actxserver('Excel.Application'); set(xl,'Visible',1);
xl.Workbooks.Add(1); xls = xl.ActiveSheet;
% Paste in the MATLAB figures
print(f1, '-dbitmap'); xls.Range('E3').PasteSpecial;
print(f2, '-dbitmap'); xls.Range('I3').PasteSpecial;
% CDF SHORT-TERM
CDFmed_st = zeros(Ccdf_tmed, Cyears);
CDFmax_st = zeros(Ccdf_tmax, Cyears);
CDFmin_st = zeros(Ccdf_tmin, Cyears);
for n=(1:Cyears)
for m=(1:Cdays)
CDFmed_st(:,n) = CDFmed_st(:,n) + (xcdf_tmed>=TMED(m,n));
CDFmax_st(:,n) = CDFmax_st(:,n) + (xcdf_tmax>=TMAX(m,n));
CDFmin_st(:,n) = CDFmin_st(:,n) + (xcdf_tmin>=TMIN(m,n));
end
end
CDFmed_st = CDFmed_st/Cdays;
CDFmax_st = CDFmax_st/Cdays;
CDFmin_st = CDFmin_st/Cdays;
figure(5)
plot(xcdf_tmed, CDFmed_lt, '*-b'); hold on; % Pongo el plot azul aca solo para que se vea bien el legend
for n=(1:Cyears)
plot(xcdf_tmed, CDFmed_st(:,n), '.-r');
end
plot(xcdf_tmed, CDFmed_lt, '*-b'); hold off;
title('CDFs de Temperatura Media');
legend('Largo Plazo', 'Corto Plazo');
xlabel('Temperatura (°C)');
ylabel('CDF');
figure(6)
plot(xcdf_tmax, CDFmax_lt, '*-b'); hold on; % Pongo el plot azul aca solo para que se vea bien el legend
for n=(1:Cyears)
plot(xcdf_tmax, CDFmax_st(:,n), '.-r');
end
plot(xcdf_tmax, CDFmax_lt, '*-b'); hold off;
title('CDFs de Temperatura Maxima');
legend('Largo Plazo', 'Corto Plazo');
xlabel('Temperatura (°C)');
ylabel('CDF');
figure(7)
plot(xcdf_tmin, CDFmin_lt, '*-b'); hold on; % Pongo el plot azul aca solo para que se vea bien el legend
for n=(1:Cyears)
plot(xcdf_tmin, CDFmin_st(:,n), '.-r');
end
plot(xcdf_tmin, CDFmin_lt, '*-b'); hold off;
title('CDFs de Temperatura Minima');
legend('Largo Plazo', 'Corto Plazo');
xlabel('Temperatura (°C)');
ylabel('CDF');
%Estadistico FS
FS=zeros(1, Cyears);
for k=(1:Cyears)
FS(k)=sum(abs(CDFmed_st(:,k)-CDFmed_lt))/Ccdf_tmed;
end
FS =FS';
xlswrite('FSTemperaturaEnero.xlsx', FS, 'Hoja1', 'A1'); %para guardar los FS de datos como Temperatura y usarlos para ponderación
but i want to export all this graphs in excel. please help
Thank you so much
best!
Ana S.

Risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by