How to find a x values from this curve (the figure (10)) from the plot?

4 Ansichten (letzte 30 Tage)
Hi everybody, i hope you all have a great day, well this is my program, but i want for specifically to the figure 10 find the values of a specific value of y that "y" is in this programm CDFmed_lt , the value that i want to find is .33 for Y, so i want to find what is the X values for a .33 value
clear;clc;
Cyears = 9;
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');
% 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
figure(8)
MSKmin = (FS == min(FS));
plot(xcdf_tmed, CDFmed_lt, 'o-','color', 'b','markersize',3,'markerfacecolor','b'); hold on;
% plot(xcdf, CDFmed_st(:, MSKmin), '.-g');
for n=(1:Cyears)
if n==1 h=[0 0.5 1]; %estos son colores , códigos de colores
end
if n==2 h=[0.7 0 0];
end
if n==3 h=[0 0.5 0];
end
if n==4 h='m';
end
if n==5 h=[0.6 0.5 0];
end
if n==6 h=[1 .75 0]';
end
if n==7 h='k';
end
if n==8 h=[0.8 0.5 0.06];
end
if n==9 h='y'; end
if n==10 h=[2 0.5 0.06];
end
if n==find(MSKmin) h=[1 0 0]; %rojo que es el FS MIN, el mas cercano a largo plazo
end
plot(xcdf_tmed, CDFmed_st(:,n),'o-','color', h,'markersize',3,'markerfacecolor',h);
end
hold off;
title('CDFs Temperatura Enero');
legend('CDF Largo Plazo','2011','2012','2013','2014','2016','2017,el mejor','2018','2019','2020','10')
xlabel('Temperatura (°C)');
ylabel('CDF');
figure(9)
MSKmin = (FS == min(FS));
plot(xcdf_tmed, CDFmed_lt, 'o-','color', 'b','markersize',3,'markerfacecolor','b'); hold on;
% plot(xcdf, CDFmed_st(:, MSKmin), '.-g');
for n=(1:Cyears)
if n==1;
end
if n==2;
end
if n==3;
end
if n==4;
end
if n==5;
end
if n==6;
end
if n==7;
end
if n==8;
end
if n==9;
end
if n==10;
end
plot(xcdf_tmed, CDFmed_st(:,8),'o-','color', 'm','markersize',3,'markerfacecolor','m');
plot(xcdf_tmed, CDFmed_st(:,6),'o-','color', 'r','markersize',3,'markerfacecolor','r');
plot(xcdf_tmed, CDFmed_st(:,7),'o-','color', 'k','markersize',3,'markerfacecolor','k');
end
hold off;
title('CDFs Temperatura Enero');
legend('CDF Largo Plazo','2019-El segundo mejor','2017-El mejor','2018-El peor')
% legend('CDF Largo Plazo', 'CDF con menor FS', 'CDFs Corto Plazo', 'CDFs Corto Plazo', 'CDFs Corto Plazo', 'CDFs Corto Plazo')
xlabel('Temperatura (°C)');
ylabel('CDF');
longterm = mean(TMED,2); % promedio de matrices por renglones
%percentiles 33 y 67
figure(10)
plot(xcdf_tmed, CDFmed_lt, '*-b'); hold on; % Pongo el plot azul aca solo para que se vea bien el legend
% perc = hline(0.33,'r', 'Percentil 33');
% perc2 = hline(0.67,'r', 'Percentil 67'); hold on
% [xcdf_tmed, CDFmed_lt] = ginput(2)
plot(xcdf_tmed, CDFmed_lt,'.m', 'MarkerSize', 20)
title('CDFs de Temperatura Media');
legend('Enero, Largo Plazo');
xlabel('Temperatura (°C)');
ylabel('CDF');
Thank you so much for your valious time.
Best

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 14 Jun. 2020
This will give you x-value from xcdf_tmed, whose corresponding y-value is closest to 0.33
[~, idx] = min(abs(CDFmed_lt-0.33));
xcdf_tmed(idx)

Weitere Antworten (0)

Kategorien

Mehr zu View and Analyze Simulation Results finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by