creating a for loop with multiple conditions.
Show older comments
Hello,
I have the following data
TEST DATE RESULT_A RESULT_B
in a table format
I'm trying to reformat so that if the test name is the same and date is the same then print a header and tabulate the rest of the results. else create a new header.
here is the code I have but it keeps creating a header for each row.
a= test
b= date
d=RESULT_A
e=RESULT_B
j=1:length(b)
for i = 1:length(a)-1
if strcmp(a{i},a{i+1}) && datenum(b{j,1})== datenum(b{j+1,1})
fprintf('\n\n\n\n%s\t%s \n','TEST' ,a{i})
fprintf('%s\t%s\n','DATEFORMAT','yyyy-mm-dd')
fprintf('%s\t%s\n','DATE',b{i})
fprintf('%s\n','"RESULT_A" "RESULT_B"')
fprintf('%s\t%s\t\n','RESULT_A','RESULT_B')
fprintf('%d\t%d\n',d(i),e(i)
end
end
Answers (0)
Categories
Find more on Test Model Components in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!