how to link an excel file containing inputs and output columns with Matlab

조회 수: 4 (최근 30일)
Mohsin Munir
Mohsin Munir 2021년 8월 25일
댓글: Mohsin Munir 2021년 8월 31일
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

답변 (2개)

dpb
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.

Walter Roberson
Walter Roberson 2021년 8월 26일
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)'}
a = 3×3 cell array
{'1'} {'2'} {'=sum(a1,b1)'} {'4'} {'5'} {'=sum(a2,b2)'} {[4]} {[5]} {'=sum(a3,b3)'}
writecell(a,filename)
t = readtable(filename, 'readvariablenames', false)
t = 1×3 table
Var1 Var2 Var3 ____ ____ _______________ 4 5 {'=sum(a3,b3)'}
c = readcell(filename)
c = 3×3 cell array
{'1'} {'2'} {'=sum(a1,b1)'} {'4'} {'5'} {'=sum(a2,b2)'} {[4]} {[5]} {'=sum(a3,b3)'}
[P,Q,R] = xlsread(filename)
Error using xlsread (line 257)
XLS File contains unicode text which is not yet supported.
  댓글 수: 1
Mohsin Munir
Mohsin Munir 2021년 8월 31일
Thanks for the reply. but i am still facing the same problem as mentioned above. I want to link excel formula in the matlab for which i need to have an efficent way.

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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by