Counting zero rain data

Versión 1.0.0 (1,76 KB) por Helin Qais
this is a simple way to calculate for zero raining data, shows which year has zero data for rains
1 descarga
Actualizado 25 dic 2023

Ver licencia

% Your data
Country = {'Iraq';'Iran';'Syria';'UAE';'Egypt';'Yemen'};
Y1990 = {'0';'700';'500';'350';'0';'800'};
Y1991 = {'550';'600';'730';'440';'600';'660'};
Y1992 = {'670';'500';'900';'870';'700';'260'};
Y1993 = {'200';'400';'550';'640';'0';'770'};
Y1994 = {'220';'610';'490';'0';'0';'0'};
Y1995 = {'400';'730';'550';'850';'560';'890'};
Y1996 = {'350';'440';'110';'490';'300';'980'};
Y1997 = {'270';'370';'560';'0';'660';'770'};
Y1998 = {'0';'800';'0';'900';'0';'880'};
Y1999 = {'420';'410';'890';'740';'0';'330'};
Y2000 = {'920';'710';'810';'660';'450';'0'};
Data = table(Country, Y1990, Y1991, Y1992, Y1993, Y1994, Y1995, Y1996, Y1997, Y1998, Y1999, Y2000);
% Initialize output table
OutputData = table();
% Iterate through each row
for i = 1:size(Data, 1)
% Get the country name
countryName = Data.Country{i};
% Extract the rain data for the current country
rainData = cellfun(@str2double, Data{i, 2:end});
% Find years with zero rain
zeroRainYears = Data.Properties.VariableNames(1 + find(rainData == 0));
% Count of zero rain years
zeroRainCount = numel(zeroRainYears);
% Add a row to the output table
OutputData = [OutputData; table({countryName}, zeroRainCount, {strjoin(zeroRainYears, ', ')}, 'VariableNames', {'Country', 'ZeroRainCount', 'ZeroRainYears'})];
end
% Display the output table
disp(OutputData);

Citar como

Helin Qais (2024). Counting zero rain data (https://www.mathworks.com/matlabcentral/fileexchange/156827-counting-zero-rain-data), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2023b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Etiquetas Añadir etiquetas

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión
1.0.0