jeudi 30 juin 2016

xlswrite: Showing variable name in sheet name or somewhere

  1. I am using xlswrite.

I am putting lots of variables into different sheets of one xlsx file.

One variable for one sheet.

So I want to put the name of the variable as the name of the sheet.

I couldn't find any command which does this. So perhaps this should be done by coding some python and having one line in matlab which calls that py file.

  1. If this is impossible, I will just try to put the name of the variable in the first row. However, when the variable has more than 1 column, then it says vertcat doesn't work.

    xlswrite('test.xlsx',vertcat('A', [1 3; 1 2]))

What should I do?

======================

A follow-up question

I coded the following based on Suever's answer.

function xlswr(file_name,varargin)
xlswrite(file_name,varargin{i},inputname(i+1))

However, when I call this function by

xlswr('test.xlsx', A, A(:,2))

then A is printed on test.xlsx, but A(:,2) was not.

Whenever the input is not just whole name like A, but some part of the variable, then it doesn't print it out.

How can I fix this?

Aucun commentaire:

Enregistrer un commentaire