How to make matlab wait for a value to be input in an empty excel cell

1 Ansicht (letzte 30 Tage)
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!

Akzeptierte Antwort

Image Analyst
Image Analyst am 14 Nov. 2016
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 Kommentar
Kota Matsuo
Kota Matsuo am 15 Nov. 2016
Bearbeitet: Kota Matsuo am 15 Nov. 2016
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 ;)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by