create a double loop with the iteration n and m evaluating a vector at 1,1 1,2 1,3 and so on in matlab

To create a double loop in MATLAB to iterate over a vector using the iteration variables n and m, you can use nested for loops. Here's an example of how you can do it:

main.m
% Suppose you have a vector to be evaluated
vector = [1, 2, 3, 4, 5];

% Define n and m
n = 4;
m = 3;

% Nested for loops
for i = 1:n
    for j = 1:m
        % Evaluate the vector at position (i,j)
        value = vector((i-1)*m + j);
        
        % Display the value
        disp(value);
    end
end
305 chars
18 lines

In this example, the outer loop iterates i from 1 to n, representing the row index, and the inner loop iterates j from 1 to m, representing the column index. The position (i,j) in the nested loop corresponds to the index (i-1)*m + j in the vector. Finally, you can perform any evaluation you need inside the inner loop, such as displaying the value as shown above.

related categories

gistlibby LogSnag