Create a function in MATLAB that finds the maximum value of

Create a function in MATLAB that finds the maximum value of X and its position, i.e. index using:

• arithmetic operations (+, -, *,/)

• logical operations (<,<=,==,>=, >, &&, ||, ~,~=)

• conditional statements (if… elseif… else… end)

• loops (while loop, for loop) • I/O (display, input())

• Scalars, vectors, and matrices

Solution

>> a=[12 5 48 5 23 6];
>> mx=a(1);
for p=2:numel(a)
if a(p)>mx
mx=a(p);
end
end
>> mx

mx =

48

Create a function in MATLAB that finds the maximum value of X and its position, i.e. index using: • arithmetic operations (+, -, *,/) • logical operations (<

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site