Hello Maciej,
The error you are getting is due to invalid indexing. MATLAB follows 1-based indexing i.e. the first index is 1. Here is an example to deal with arrays in MATLAB:
% Example arrays A and B
A = [5]; % Can be of size 1 to x
B = [3]; % Can be of size 1 to x
% Determine the size of the array
n = numel(A); % Get the number of elements in A
% Initialize a variable to store the result
result = false;
% Loop through the array with safe indexing
for i = 1:n
% Check the condition with safe indexing
if (i == 1) && (A(i) >= B(i))
result = true;
break; % Exit the loop if condition is met
end
end
% Display the result
if result
disp('Condition met: A[i] >= B[i] for i == 1');
else
disp('Condition not met.');
end
I hope this resolves your query.