Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting undefined variable with if exist

Tags:

matlab

I assume this is a trivial mistake on my part but it is driving me nuts.

???Undefined function or variable "antenna_02".

Error in ==>test_model at 6
if exist(antenna_02.mat, 'file')

I know it isn't defined that is why I am using if exist. Any help would be gladly appreciated and may just save my sanity.

like image 286
Azathoth Blindidiotgod Avatar asked Jan 13 '23 01:01

Azathoth Blindidiotgod


1 Answers

You need to enclose "antenna_02.mat" in apostrophes (''):

if exist('antenna_02.mat', 'file')

Otherwise MATLAB tries to interpret it as a structure variable and complains that there's no variable called antenna_02.

like image 176
Eitan T Avatar answered Jan 16 '23 01:01

Eitan T