Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Read or Write an Excel file in Matlab.

Asked by 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

C Zeng on 24 Jul 2013

Sorry, 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

For xlsread, yes I used them one at a time repeatedly. Each time read a value from a cell in Excel file, and assign the value to a new variable.

Thanks.

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

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.

C Zeng

Products

1 Answer

Answer by Tinky on 21 Sep 2013

Make use of next item excel repair xlsx

Learn this solution http://www.repairxlsx.xlsxrepairtoolbox.com

0 Comments

Tinky

Contact us