Continue with script despite an absent variable (error)?
이전 댓글 표시
Hello, so I have a script that analyzes several variables on a truck (such as engine speed, GPS coordinates, etc.), and it makes sure the variables are within a certain range and that they exist. One of our variables, DPF temperature, is often absent, and I am wondering if there is a way to continue running my script even though Matlab shows an error saying the DPF temp variable does not exist? Here is the DPF temp code...
if exist('CAN2_THMM_03158_MSG0_DPF_INLET')==0; %#ok<EXIST>
disp('--An error has occurred in "CAN2_THMM_03158_MSG0_DPF_INLET" - Data does not exist.');
else
x = min(CAN2_THMM_03158_MSG0_DPF_INLET);
y = max(CAN2_THMM_03158_MSG0_DPF_INLET);
if any( y > 800 | x < -25)
disp('--An error has occurred in "CAN2_THMM_03158_MSG0_DPF_INLET" - Data outside accepted range.');
end
Matlab will recognize that 'CAN2_THMM_03158_MSG0_DPF_INLET' does not exist, and it will show an error and stop the entire script. How do I prevent this?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!