is there a command in matlab for waiting
古いコメントを表示
its needed sometimes matlab do nothing and not going next command line, till a specified thing happens.for example:
clc
clear all
g=[];
plot(r,'YDataSource','r');ylim([0 y1]);Xlim([0 x1])%r is a defined matrix
-(now after plotting, i want make a matrix in 'result' name manually but since now this matrix isn't defined so i need matlab wait here till i defined it)
if 'rezult' not exist
wait
end
for i=1:10
g=[g;result(i,i+1)] %if didn't wait, errors for defining of 'result'
end
採用された回答
その他の回答 (4 件)
Rick Rosson
2011 年 9 月 9 日
if isempty(result)
...
else
...
end
4 件のコメント
Walter Roberson
2011 年 9 月 9 日
No, an empty matrix still exists!
Rick Rosson
2011 年 9 月 9 日
Maybe. But a matrix that does not exist will return |true| from the |isempty| function.
Walter Roberson
2011 年 9 月 9 日
I really think you need to test that, Rick. I think you will find that instead MATLAB will error out for trying to use an undefined variable.
Perhaps you are being influenced by the fact that persistent variables and global variables will be empty matrices until some other value is assigned to them?
Rick Rosson
2011 年 9 月 9 日
Yes, you are right. This solution will not work.
Oleg Komarov
2011 年 9 月 9 日
1 投票
Rick Rosson
2011 年 9 月 9 日
Alternatively:
if exist('result','var')
...
else
...
end
HTH.
Rick
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!