0

I'm using the PrintTable method of the matlabtools. In the documentation the following example is given:

t = PrintTable('LaTeX/PDF export demo, %s',datestr(now));
t.HasRowHeader = true;
t.HasHeader = true;
t.addRow('A','B','C');

Let's say I have the header names in a cell array header = {'A','B','C'}. Unfortunately a cell array cannot be passed to addRow, i.e. t.addRow(header); does not work. Unfortunately the size of the header varies in my case, that's why I'm storing it in a cell array.

How can I call the addRow method with a variable sized cell array?

1
  • 2
    You should convert header to a comma separated list: t.addRow(header{:}); Commented Oct 23, 2017 at 20:20

1 Answer 1

1

Two ways. The second way would be more elegant in the script but the first way is more functional as you can create the cell using code and can still call it in your script. In the second way, you can't do that.

  • Encapsulate what you have in a cell (i.e. 1 variable): t.addRow({'A', 'B', 'C'}) and your function addRow would just ask about the length of the cell and proceed accordingly.

  • Use optional args as described here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.