MATLAB Basics set 5

Que.What is the output of the following command?
function mad= heart(p,varargin)
disp(p)
wish=sin(varargin{0})
end
p=heart(1:3,0)

a. Error in wish command
b. Error while calling heart command
c. Error while calling disp command
d. 1 2 3wish=0
Que.What is the output of the following command?
function mad= rush(p,varargin)
disp(p)
wish=cos(varargin[0])
end
p=rush(1:3,pi/2)

a. Error due to element index
b. Error due to syntax of varargin
c. 1 2 3wish=0
d. Error due to disp()
Que.What is the output of the following code?
function mad= rush(p,varargin)
disp(p)
wish=cos(varargin{1})
end
p=rush(1:3,Inf)

a. Error due to Inf
b. -1
c. p{1}= 1 2 3wish=0
d. p{1}= 1 2 3wish=NaN
Que.What is the output of the following code?
function maha= orchid(polo,varargin)
disp(polo)
wish=sum(varargin{1,2})
end
p=rush(-1:1,Inf)

a. Logical error in varargin
b. Syntactical error in varargin
c. p{1}=-1 0 1wish=0
d. No output
Que.What is the output of the following code?
function [die,absdif] = BDO(y,x)
die = y-x;
if nargout > 1
    disp('Boo !')
    absdif = abs(die);
end
end
[p,q]=BDO(Inf,Inf)

a. Boo!p=NaNq=NaN
b. Boo!p=0q=0
c. Error
d. p=NaN
Que.What is the output of the following code?
function [die,af] = Bod(y,x)
die = y*x;
if nargout < 1
    error('Boo !')
 else
   disp(‘Yo !’)
   af = abs(die);
end
end
[p]=Bod(1,[1 -2])

a. Error with Boo! displayed
b. Yo !p=1
c. Yo !p=2
d. Yo !p=-2
Que.What is the output of the following code?
function [die,af] = lola(y,x)
die = y*x;
if nargout < 1
    error('Boo !')
 else
   disp(‘Yo !’)
   af = abs(die);
end
end
p=lola(1,[1 -2])

a. Error with Boo ! written
b. Yo !p=-2
c. Boo !p=-1
d. Boo !p=1
Que.A function ______________
a. can be run in the command window by defining it in the window itself
b. can be run in the command window by defining it in a cpp file
c. can be run in the command window by defining it in a script file
d. can be run in the script file by defining it in the command window
Que.What is the output of the following code?
function c = addem(ap,q)
p=nargn-1
switch p
    case 2
        c = ap*q;
    case 1
        c = sin(q)
    otherwise
        c = 0;
end
addem(1,2,3,4,5,6,7,8)

a. 2
b. Error due to too many inputs
c. 28
d. Error due to nargn
Que.What is the output of the following command?
function pu= hu(p,varargin)
narginchk(0,1)
disp(‘Stick!’)
o=sin(varargin{1});
end
ola(1,p/2)

a. Error due to line 2
b. Error due to line 5
c. Error due to syntax
d. Stick!o=1

Leave a Comment