MATLAB: Error opening a text file using fopen

disp('Setting up serial communication...');
% Determine which COM port is for microcontroller and change
a = arduino('COM4','Uno');
% Open serial COM port for communication
fopen(a);
set(a,'Timeout',10);
prev_left = [0 0 0 0];
prev_right = [0 0 0 0];
prev_left_flag=0;
prev_right_flag =0;
prev_flag = 2;
check_left = 0;
check_right = 0;
check_straight_right = 0;
check_straight_left = 0;
check_left_right = 0;
check_right_left = 0;

Best Answer

It is not necessary to fopen() an arduino object: the arduino() function does any necessary opening of the device.