How to filter out missing variables for functions when importing .txt files
1 次查看(过去 30 天)
显示 更早的评论
I am importing a text file and evaluating the data in the file versus baseline data. The problem I am having is that the text file to be evaluated is sometimes missing variables.
How can I efficiently besides, using ~exist() for every variable, filter out the data that is not present
0 个评论
采纳的回答
Sean de Wolski
2013-3-29
编辑:Sean de Wolski
2013-3-29
First, I warn you that this approach of "poofing" variables might be a bad idea that could lead to difficult to debug issues further down the line.
Second, to do this efficiently you could use the structure output from whos() and ismember() to identify missing variables:
clear;
x = 1;
y = 7;
varsWanted = {'x','y','z'};
varsPresent = whos;
missing = varsWanted(~ismember(varsWanted,{varsPresent.name}));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!