Info

此问题已关闭。 请重新打开它进行编辑或回答。

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 次查看(过去 30 天)
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??

回答(0 个)

此问题已关闭。

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by