Info

This question is closed. Reopen it to edit or answer.

i have a problem in my code. I get data continous from an instrument. But at times i get a error message stated . what are the ways to overcome this error. I thought of TRY and Catch. Is it possible???

1 view (last 30 days)
Index exceeds matrix dimensions.
Error in Battery_check_new (line 107) I_eLOAD(i,:) = str2double(Data_eLOAD_Stringsplit(3));
my code is i AM OPENING THE OBJECT AND GIVING THE SET POINT; THEN IT ENTERS THE LOOP while(exit) i=i+1; tic try fprintf(eLOAD_instr, 'curr %2f',Setpoint); % Setpoint to eLOAD pause(0.1);
%%Get Data from ELR9000
% Setpoint, Current, Voltage, Power
Data_eLOAD_string = query(eLOAD_instr, 'curr?; measure:current?; measure:voltage?; measure:power?');
display('1');
catch
Display('2')
end
% Write Data_string in vector of type struct
%Data_eLOAD_string_vec{i} = Data_eLOAD_string;
Data_eLOAD_Stringsplit = strsplit(Data_eLOAD_string, {' ', ';'});
I_set(i,:) = str2double(Data_eLOAD_Stringsplit(1));
I_eLOAD(i,:) = str2double(Data_eLOAD_Stringsplit(3));
U_eLOAD(i,:) = str2double(Data_eLOAD_Stringsplit(5));
P_eLOAD(i,:) = str2double(Data_eLOAD_Stringsplit(7));
toc
end
How to use Try and catch command to overcome the error??? or any other possibility is there??

Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!