Counting zero rain data

バージョン 1.0.0 (1.76 KB) 作成者: Helin Qais
this is a simple way to calculate for zero raining data, shows which year has zero data for rains
ダウンロード 1 件
更新 2023/12/25

ライセンスの表示

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

引用

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

MATLAB リリースの互換性
作成: R2023b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0