Matlab programmingSolution2 a clc clear all close all Ninput
Matlab programming
Solution
2. a
clc;
clear all;
close all;
N=input(\'positive integer\');
v=0;
while (N>1)
N=floor(N/2);
v=v+1;
end
disp(v)
2. b.
clc;
clear all;
close all;
N=input(\'positive integer\');
v=0;
while (N>0)
d=mod(N,10);
N=floor(N/10);
v=v+1;
if(d==1)
v=v+1;
end
end
disp(v)
2.c
%reverse display of vecror%
clc;
clear all;
close all;
vec=input(\'vector enter\');
i=1;
j=length(vec);
while(i<j)
temp=vec(i);
vec(i)=vec(j);
vec(j)=temp;
end
i=i+1;
j=j+1;
disp(vec)

