Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Matlab errors
Date: Sat, 17 Mar 2012 23:10:29 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 114
Message-ID: <jk35l5$sc0$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1332025829 29056 172.30.248.35 (17 Mar 2012 23:10:29 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 17 Mar 2012 23:10:29 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3386192
Xref: news.mathworks.com comp.soft-sys.matlab:761329

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(i-9)=bs(i);
end
for i=2:9
e2(i-1)=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=e2-e;
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*i-2)*2^2+F(3*i-1)*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