フィルターのクリア

Array with random date find all the date belonging to the month of January using strfind.

2 ビュー (過去 30 日間)
Arthur Hajaali
Arthur Hajaali 2016 年 8 月 14 日
コメント済み: Arthur Hajaali 2016 年 8 月 14 日
Hi everyone, I have an array 800*7 and in the 7 column content various date of the year 2015, my goal is to classify and plot the number of cells belonging to each month of the year. All the date are of the format dd/mm/yyyy so my plan is to use the function string find such as '01/2015' for january and numel the column to calculate the exact number of cell belonging to the month of january but something is wrong with my code:
ship_table; %800*7 array.
idx = strfind(ship_table(:,7),'01/2015'); % gives me a the 800 cells with either 4 or [].
jan = numel(idx);
fprintf(jan);
Could someone help please :)
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 14 日
post three lines of your data
Arthur Hajaali
Arthur Hajaali 2016 年 8 月 14 日
here's three line of the data and actually I would like to extract in a new array the row of each cell that matches my initial string condition '01/2015'

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

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 14 日
編集済み: Azzi Abdelmalek 2016 年 8 月 14 日
Why you don't use ismember
a={1 2 3 '01/2015';4 5 66 '01/2015';1 7 4 '02/2015'}
idx = ismember(a(:,4),'01/2015') .

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 14 日
You can use datetime function. Look at this example
a={1 2 3 '01/2015';4 5 66 '01/2015';1 7 4 '02/2015'}
c4=a(:,4)
a=datetime(c4,'InputFormat','MM/yyyy')
id=month(a)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by