"if" function with cell array

조회 수: 2 (최근 30일)
Matthew Covington
Matthew Covington 2019년 4월 5일
댓글: 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
Matthew Covington 2019년 4월 5일
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