Counting zero rain data

Versione 1.0.0 (1,76 KB) da Helin Qais
this is a simple way to calculate for zero raining data, shows which year has zero data for rains
1 download
Aggiornato 25 dic 2023

Visualizza la licenza

% 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);

Cita come

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

Compatibilità della release di MATLAB
Creato con R2023b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Tag Aggiungi tag

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
1.0.0