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!

采纳的回答

Image Analyst
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
  1 个评论
Kota Matsuo
Kota Matsuo 2016-11-15
编辑:Kota Matsuo 2016-11-15
Exactly what I need! I was looking for the "isempty" command. As you guessed I am fairly new to MATLAB. And so the timing and while loop structure you wrote is also very helpful for me. Thank you so much!
P.S. I took a look at your demos and tutorials on your File Exchange. Your work looks very interesting! I will definitely go through them ;)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by