writeTable won't take my parameters

6 views (last 30 days)
Laura Dillon
Laura Dillon on 21 Aug 2019
Answered: Star Strider on 21 Aug 2019
titles={'the' 'hungry' 'dog'}
a=['22b' ; '22c' ; '22d']
b=['23d' ; '23e' ; '34f']
myData=table(a,b, 'VariableNames', titles);
writeTable(myData ,' 'myData.xlsx');
Error using table (line 255)
Wrong number of arguments.
Hi all, this is my code it won't run for some reason
Thanks

Answers (1)

Star Strider
Star Strider on 21 Aug 2019
The error was with table, not writetable. You are not creating the table correctly.
Try this:
titles={'the' 'hungry' 'dog'}
a={'22b' ; '22c' ; '22d'}
b={'23d' ; '23e' ; '34f'}
myData = array2table([a, b]', 'VariableNames', titles)
producing:
myData =
2×3 table
the hungry dog
_____ ______ _____
'22b' '22c' '22d'
'23d' '23e' '34f'
that I assume is what you want.

Categories

Find more on Tables 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!