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