how to calculate the maximum of a vector in matlab

To calculate the maximum value of a vector in MATLAB, you can use the built-in max function.

main.m
v = [1, 2, 3, 4, 5];
max_value = max(v);
disp(max_value); % output: 5
70 chars
4 lines

In this example, we create a vector v of integers, and then use the max function to store the maximum value of the vector in the max_value variable. The disp function is then used to display the value of max_value in the command window.

related categories

gistlibby LogSnag