Writing data from Matlab to Excel Macro sheet

I want to export the data generated in Matlab, to be written into .xlsm file.
I have my Matlab file generated in C folder and my macro excel file is in D folder.
I wan to send this following data to the .xlsm file.
5×5 string array
"10" "HPP" "ELS" "HFS" "MINT"
"19" "HPP" "PC" "HFS" "MINT"
"21" "HPP" "PC" "HFS" "PR"
"" "" "" "" ""
"" "" "" "" ""
Any help would be really appreciated and I would be greatful.

댓글 수: 1

the location of the excel file is : "D:\CVT\VBA\Practice of the tradspace updated file.xlsm" and I want to export the data from Matlab to this excel macro file

댓글을 달려면 로그인하십시오.

 채택된 답변

Sai Sri Pathuri
Sai Sri Pathuri 2020년 4월 28일

0 개 추천

You may use writematrix function to write the string array to macro excel sheet by giving the full path of macro excel sheet as filename.
filename = 'D:\CVT\VBA\Practice of the tradspace updated file.xlsm';
writematrix(stringArray,filename);

댓글 수: 3

Thank you very much. So far I have discovered that this function does not write into the original excel file from where, I am getting all the data into Matlab. Therefore, I have to create a new file with whatsoever name of the file and export the data into that.
But with this function, thing is working.
Thank you very much for the help.
I have a question regarding the exporting the data only if you could help me in that,
WRight now, I can export the data into Excel file and the data has been exectly written as Martlab. for example, in Matlab and in the above example in the string array, it is, "10" "HPP" "ELS" "HFS" "MINT".
and it is being written into excel horizontally. Can I convert this into vertical when I tend to send the data to excel?
If you want to write all the rows vertically, you may transpose the string array and write it
writematrix(stringArray',filename);
I thaught so but was not sure but I checked it with some samll changes this works.
Thank you very much again for the help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

질문:

2020년 4월 25일

댓글:

2020년 4월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by