Read or Write an Excel file in Matlab.
Show older comments
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
on 24 Jul 2013
Probably causing errors? Who knows w/o any more info than that provided?
Can you execute the commands in sequence and isolate a cause? Perhaps you're trying to access a worksheet that's already open and thereby locked? Perhaps there's an actual problem w/ the Excel installation--checked for updates lately?
C Zeng
on 24 Jul 2013
dpb
on 24 Jul 2013
W/O code anything is purely speculation...what's "a lot" and how are you writing them--one at a time repeatedly, as an array, ...???
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
on 25 Jul 2013
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!