On Mar 17, 7:10 pm, "Abdo " <ae...@aub.edu.lb> wrote:
> hello everyone I'm new here and I was wandering if you could help me with this program...
>
> My code:
>
> function o = convertSingletoOctal(bs)
> F2=zeros(1,23);
> e2=zeros(1,8);
> for i=10:32
> F2(i9)=bs(i);
> end
> for i=2:9
> e2(i1)=bs(i);
> end
> [E8,F8,e8]=Convert2to8Exp(F2,e2);%Calling the function Convert2to8Exp
> t=bs(1);
> if t == 1
> o=disp(['o =  ', num2str(E8),'.',num2str(F8),' * 8^',num2str(e8)]);
> elseif t == 0
> o=disp(['o = + ', num2str(E8),'.',num2str(F8),' * 8^',num2str(e8)]);
> end
> end
>
> Convert2to8Exp function=
>
> function [E8,F8,e8]=Convert2to8Exp(F2,e2)
> [E,F,e]= ShiftBinary(F2,e2);%Calling the function
> %Converting the integral part
> r=e2e;
> if(r==0)
> E=[0 0 E];
> elseif(r==1)
> E=[0 E];
> end
> E8=(E(1)*2^2)+(E(2)*2)+E(3);
>
> %Converting the fractional part
> k =length(F);
> re=rem(k,3);
> if(re==1)
> F=[F 0 0];
> elseif(re==2)
> F=[F 0];
> end
> k1 = length(F);
> o = k1/3;%number of octal triplets
> F8=zeros(1,8);
> for i=1:o
> F8(i)=F(3*i2)*2^2+F(3*i1)*2+F(3*i);
> end
> %Computing the exponent
> e8=e/3;
> end
>
> Shift Binary function:
>
> function [E , F, e] = ShiftBinary(F2, e2)
> q = floor (e2/3);
> r = rem (e2,3);
> if (r==1)
> E= [1 F2(1)];
> F= F2(2:(length(F2)));
> elseif (r==2)
> E= [1 F2(1) F2(2)];
> F= F2(3:(length(F2)));
> elseif (r==0)
> E= 1;
> F= F2(1:length(F2));
> end
> e = 3 * q;
> end
>
> The error:
>
> Error in ==> ShiftBinary at 7
> q = floor (e2/3);
>
> ??? Output argument "E" (and maybe others) not assigned during call to
> "C:\Users\ABDO\Documents\MATLAB\ShiftBinary.m>ShiftBinary".
>
> Error in ==> Convert2to8Exp at 8
> [E,F,e]= ShiftBinary(F2,e2);%Calling the function
>
> Error in ==> convertSingletoOctal at 14
> [E8,F8,e8]=Convert2to8Exp(F2,e2);%Calling the function Convert2to8Exp
>
> Thank you for your help
How would you feel if someone asked you to find mistakes in a long,
sparsely
commented, code without telling you what the program is supposed to do
and
how you are trying to accomplish the task?
Greg
