how to link an excel file containing inputs and output columns with Matlab
12 ビュー (過去 30 日間)
古いコメントを表示
I have an excel file in which some coulmns have data entered by user and some columns are output using some formula. I dont want to apply these formulae again in Matlab rather i want to link my excel file to matlab so that any change in the input will be directly changed in the Matlab. The columns in excel showing formula shall be read as formula by the Matlab. If anyone knows about it please share
0 件のコメント
回答 (2 件)
dpb
2021 年 8 月 25 日
The builtin functions in MATLAB to read/write Excel files read only the data content from cells, not the formulas contained in cells. To do the latter will require using the ActiveX and writing the VBA equivalent. This is more of an Excel VBA syntax issue than MATLAB.
0 件のコメント
Walter Roberson
2021 年 8 月 26 日
The post https://www.mathworks.com/matlabcentral/answers/91569-will-it-be-possible-to-use-xlswrite-to-write-formulas-to-the-excel-sheet-which-would-be-calculated-a#answer_100920 from years ago appears to claim that you can write formulas using xlswrite().
I cannot demonstrate here using xlswrite() as it is not supported on this online system. But you can see that for using writecell() instead, it does not work... and it gets odd for .xls files (but does not get odd for xlsx files)
filename = [tempname() '.xls'];
cleanMe = onCleanup(@() delete(filename));
a={'1','2','=sum(a1,b1)'};
a(2,:)={'4' '5' '=sum(a2,b2)'};
a(3,:)={4, 5 ,'=sum(a3,b3)'}
writecell(a,filename)
t = readtable(filename, 'readvariablenames', false)
c = readcell(filename)
[P,Q,R] = xlsread(filename)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!