"if" function with cell array
4 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on MATLAB Mobile in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!