I have a two cell arrays, one consisting of food items to eat and another of what not to eat.
For example: C = {'ham', 'cheese', 'bread'} <— food to eat and D = {'milk', 'apples', 'cherry'}
I need to put the items from both cell arrays into a string that is formatted like this:
'I can eat ham, cheese and/or bread, but do not eat milk, apples or cherry'
The number of elements in the cell arrays will not always be three; it is not consistent.
I am having trouble separating elements with commas and the last two items with an 'and/or' and 'or.'
There should not be a comma before the 'and/or' or the 'or.'
Also if there are only two items in a cell array then the output string should look lik this: 'I can eat ham and/or cheese, but do not eat milk or apples'
where there are no commas.
Best Answer