where is the error ?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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
Walter Roberson
on 2 Dec 2018
what error are you encountering ?
KHAIF HICHEM
on 2 Dec 2018
Image Analyst
on 2 Dec 2018
You aren't just clicking the green Run triangle without passing in vect are you???
Adam Danz
on 2 Dec 2018
That's my bet (what Image Analyst said). If you'd like to run your code with default values for when there are no inputs specified, add this to the top of your code.
if nargin == 0
vect = [1 2 3 4 5]; %whatever your default values are
warning('Default values entered in %s.m', mfilename)
end
KHAIF HICHEM
on 2 Dec 2018
Walter Roberson
on 2 Dec 2018
defining the variable in the base workspace is not enough .you need to go to the command line and
mini(v)
KHAIF HICHEM
on 3 Dec 2018
Answers (1)
In the command line, where you defined v, call the function this way:
>> v= [1 2 3 ;4 5 6];
>> mini(v)
This question is closed.
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!