필터 지우기
필터 지우기

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

채택된 답변

Sean de Wolski
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 CenterFile Exchange에서 Whos에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by