Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fogler Problem 7-8 Input code needed to get this code to work in MATLAB % This i

ID: 3600008 • Letter: F

Question

Fogler Problem 7-8 Input code needed to get this code to work in MATLAB

% This is a template for solution of Fogler Problem 7-8.

%

% Please complete and publish to PDF. Please submit the PDF to D2L at the In-

% Class dropbox for this date.

%

% You may work in groups of two but every student must submit their own PDF.

%% Data

cao=0.1; % mol/dm3

cbo=1; % mol/dm3

%data from table 1

ca1=[1.0,0.95,0.816,0.707,0.50,0.370]; % mol/dm3

t1=[0,0.278,1.389,2.78,8.33,16.66]; % h

cao1=ca1(1);

%data from table 2

ca2=[0.1,0.0847,0.0735,0.0526,0.0357]; %mol/dm3

t2=[0,1,2,5,10]; % h

cao2=ca2(1);

%% fit data from table 2 to determine m and k1

%p = [m k1]

fitfun2= @(p,t)                     ;

p0=[ , ];

[p,R,~,Cov]=nlinfit(t2,ca2,fitfun2,p0);

perr=sqrt(diag(Cov));

m=p(1);

merr=perr(1);

k1=p(2);

k1err=perr(2);

disp(['m= ',num2str(m),' ± ',num2str(merr)])

disp(['k1= ',num2str(k1),' ± ',num2str(k1err)])

R2=1-sum(R.^2)/sum((ca2-mean(ca2)).^2)

%% plot fit

legend('measured','fit')

ylabel('C_A / mol dm^{-3}')

xlabel('time / h')

figure(gcf)

%% fit data using table 1 to determine k and n

%p =[ n, k]

fitfun2=@( , )                              ;

[p,R,~,Cov]=nlinfit(t1,ca1,fitfun2,[1,0.01]);

perr=sqrt(diag(Cov));

n= ;

nerr= ;

k= ;

kerr= ;

R2= ;

disp(['n= ',num2str(n),' ± ',num2str(nerr)])

disp(['k= ',num2str(k),' ± ',num2str(kerr)])

%% plot fit

legend('measured','fit')

ylabel('C_A / mol dm^{-3}')

xlabel('time /h')

figure(gcf)

Input code needed to get this code to work in MATLAB

Explanation / Answer

Stack stack = new Stack(); while (n > 0) { stack.push(n % 2); n /= 2; } while (!stack.isEmpty()) StdOut.print(stack.pop()); StdOut.println(); Stack stack = new Stack(); while (!queue.isEmpty()) stack.push(queue.dequeue()); while (!stack.isEmpty()) queue.enqueue(stack.pop());