"if" function with cell array

6 次查看(过去 30 天)
Matthew Covington
评论: Rik 2019-4-6
I am using the following code:
for n = 1:numbers_rows %numbers_rows = 32
if words{n, 3} == 's'
fprintf('%02.0f/%02.0f/%d ', numbers(n, 1), numbers(n, 2), numbers(n, 3))
fprintf('%s\n', words{n,2})
end
end
and getting the following output:
Date Opponent
01/10/2019 Tennessee
01/14/2019 Florida
01/17/2019 Alabama
01/24/2019 Mississippi State
01/27/2019 Vanderbilt University
01/31/2019 Texas A&M
02/03/2019 Mizzou
02/07/2019 Ole Miss
02/10/2019 Georgia
02/14/2019 Kentucky
02/17/2019 Arkansas
02/24/2019 Tennessee
02/28/2019 Alabama
03/03/2019 Missouri
03/07/2019 South Carolina
03/08/2019 LSU
03/23/2019 ALABAMA
The ouput I am looking for is:
01/03/2019 Tennessee
01/06/2019 Florida
01/10/2019 Alabama
01/14/2019 Mississippi State
01/17/2019 Vanderbilt University
01/24/2019 Texas A&M
01/27/2019 Mizzou
01/31/2019 Ole Miss
02/03/2019 Georgia
02/07/2019 Kentucky
02/10/2019 Arkansas
02/14/2019 Tennessee
02/17/2019 Alabama
02/24/2019 Missouri
02/28/2019 South Carolina
03/03/2019 LSU
03/07/2019 ALABAMA
03/08/2019 TEXAS A&M
As you can tell, the dates and opponents do not match up. Im not sure what Im doing wrong. The data that was extracted is attacthed. I extracted it using xlsread() as I was instraucted to do. Also this is where numbers_rows comes from in the for loop
[numbers, words, everything] = xlsread(FILENAME);
[numbers_rows, numbers_columns] = size(numbers);
  2 个评论
Matthew Covington
I figured it out my mistakes, my bad
Rik
Rik 2019-4-6
Then you should either post the solution, or delete the question.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Mobile 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by