Finding single digit number from the data

9 ビュー (過去 30 日間)
Seoyoung Cho
Seoyoung Cho 2020 年 1 月 28 日
コメント済み: Rena Berman 2020 年 5 月 14 日
What date(s) have at least 5 single-digit numbers within the winning number set?
  1 件のコメント
Rena Berman
Rena Berman 2020 年 5 月 14 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2020 年 1 月 28 日
Is this homework? Sounds like it.
Basically use csvread() or importdata() to read in the data. Then look at columns 4 - 9 and see which are 9 or less. Untested code:
lessThan9 = data(:, 4:9) <= 9; % Logical array of what values are less than 9.
% Find out which rows have at least 5 less than 9
sums = sum(lessThan9, 2);
goodRows = sums >= 5;
% Get the dates in the separate arrays for month, day, and year
% (same format that it gave the data to us in).
goodMonths = data(goodRows, 1);
goodDays = data(goodRows, 2);
goodYears = data(goodRows, 3);
theSums = sums(goodRows)
% For fun, print them out.
for k = 1 : length(goodMonths)
fprintf('%d - %d - %d had % numbers less than or equal to 9.\n'...
goodMonths(k), goodDays(k), goodYears(k), theSums(k))
end

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by