MATLAB Answers

0

where is the error ?

Asked by KHAIF HICHEM on 2 Dec 2018
Latest activity Edited by M
on 3 Dec 2018
function [ vmin ] = mini(vect)
%MINI retourne le minimum d’un vecteur
n = numel(vect);
if n == 0
vmin = [];
else
vmin = vect(1);
for k = 2:n
if vect(k) < vmin
vmin = vect(k);
end
end
end
end
function [ vmax ] = maxi(vect)
%MAXI retourne le maxiimum d’un vecteur
n = numel(vect);
if n == 0
vmax = [];
else
vmax = vect(1);
for k = 2:n
if vect(k) > vmax
vmax = vect(k);
end
end
end
end

  8 Comments

defining the variable in the base workspace is not enough .you need to go to the command line and
mini(v)
can you show me ho to do ?

Sign in to comment.

Tags

Products

1 Answer

Answer by M
on 3 Dec 2018
Edited by M
on 3 Dec 2018

In the command line, where you defined v, call the function this way:
>> v= [1 2 3 ;4 5 6];
>> mini(v)

  0 Comments

Sign in to comment.