How to make matlab wait for a value to be input in an empty excel cell
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to do some calculations using a table on my excel file as an input to my MATLAB code. Is it possible to tell MATLAB to wait until an empty excel cell receives a value (from other programs)?
For example, consider a MATLAB code that calculates the Z column using values from the Y column. The problem is that the Y column is calculated using another (very slow) program.
X | Y | Z |
-----------
1 | 23| 91|
2 | 42| 24|
3 | 26| 34|
4 | □|___|
5 | _ | __ |
□ is the empty cell waiting for an input from the other program. Once this value is received, MATLAB calculates the Z-value, and the other program calculates the next Y-value in the next row using the Z-value just calculated from MATLAB.
My explanation might be confusing, but I hope you understand my question.
Thank you very much in advance!
0 个评论
采纳的回答
Image Analyst
2016-11-14
Can't you just put xlsread() in a loop and check the value. Then break from the loop once the cell is not empty. I'd also put a check on time since you don't want to get into an infinite loop you can't get out of, like wiat for 100 seconds or so
startTime = tic;
elapsedTime = toc(startTime);
while elaspedTime < 100
[numbers, strings, raw] = xlsread(......
if ~isempty(some cell........
break; % Exit from the loop since they entered something.
end
elapsedTime = toc(startTime);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!