How to tell a loop to wait for an iteration?
Show older comments
I am trying to read data being exported to excel from matlab in a moving window size of 5. for example I want to read rows 1:5, 2:6 etc. Ideally 10 rows of data will be transfered from matlab to excel and I want to get 6 samples from the ten rows. The loop below works fine if all the data is present before I run the loop. I am running into an issue now that if the data still didn't transfer over to excel I get empty answers for my num{cell} ( I get [] ). Is there anyway that I can tell excel to wait until the 5 first rows are added to start the loop's first iteration and then wait for an additional row to be added to do the next iteration?
for i=1:6
num{count}=xlsread('testdata.xlsm','Sheet2',strcat('A',num2str(i),':B',num2str(i + 4)));
count= count +1;
end
Also is there anyway I can take out the cells in num and have each cell be written as an array matrix?
Thank you so much!
2 Comments
Geoff Hayes
on 20 Nov 2014
Nancy - is the data going from MATLAB to Excel, or Excel to MATLAB? You are using the xlsread command so that suggests the latter, but your question mentions a couple of times that you are exporting data to Excel (in which case you should be using xlswrite). Or do you have a separate process that writes data to Excel and another that will read back from it?
Nancy
on 20 Nov 2014
Accepted Answer
More Answers (1)
Image Analyst
on 29 Nov 2014
0 votes
If you are reading data from your arduino, you should not be using xlsread() or xlswrite(). You should be using ActiveX (if you're on Windows) since it will be very much more responsive and faster. Attached is an ActiveX demo for Excel.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!