Read or Write an Excel file in Matlab.

1 view (last 30 days)
C Zeng
C Zeng on 24 Jul 2013
I used a lot of read and write functions in Matlab, xlsread and xlswrite. However when I run it pops up a lot of windows that:
Microsofe Excel has stopped working, and Windows is checking for a solution.
Why it is idle? Thanks.
  6 Comments
dpb
dpb on 24 Jul 2013
I used them in a loop, each time write a value into an Excel file but different cell in excel. Like:(note location cell will not change for different i)
For i=1:N
xlswrite('Validation.xlsx', {value{1}(m)},'Interface Inputs','I22');
xlswrite('Validation.xlsx', {value{1}(m)},'Interface Inputs','I23');
end
I don't follow--you say a different cell then expressly note that cell location will not change??? Why write the same thing multiple times?
I suspect your loop in Matlab is trying to execute faster than the COM engine can keep up and you're thus "locking up" Excel.
I don't use Excel but as a toy and have never done the link w/ Matlab other than just as an exercise here or at cs-sm for a particular syntax problem or the like so I'm sorta' guessing but--
1) Can you not write an area/block at a time rather than a single cell, and
2) I suggest use the return values from xlswrite() and inspect status and particularly the status message if indicates a failure.
3) If you think you must use the kind of structure you're using, try inserting a short pause in the loop and see if that solves the problem.
C Zeng
C Zeng on 25 Jul 2013
Hi, dpb, sorry, I wrote it just as an example, each time I am sure the cell is different. Yes, I use xlswrite commands in a sequence and that may be the cause.
Actually I have to write a cell a time, because they are not in a block or area.
Thanks for your suggestions.

Sign in to comment.

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!