ORRETTE B. answered • 12/12/13

Computer Engineering, STEM, Chemistry, Electronics, Mathematics

Create two variables for the two columns of data and plot them.

Create the time-vector t and the concentration vector C (Same as columns of data but you have to store them in Matlab memory). This is a straight execution on the Matlab Command line. Meaning I did not create a script/function. I used the built in plot function which basically plots the two variables t and C with t on the x-axis and C on the y-axis. anything after the % sign is a comment. It is highlighted in green. Comments are used to make your program more understandable.

t = 0, 50, 100, 200, 300;

C = 0.100, 0.0079, 0.0065, 0.0048, 0.0038;

plot(t,C)

grid on % Turn on grid lines for this plot

C = 0.100, 0.0079, 0.0065, 0.0048, 0.0038;

plot(t,C)

grid on % Turn on grid lines for this plot

Now that you have plot the graph your analysis begins:

Remember y = mx + c the equation of a line

C (t) = C (0)e

C (t) = C (0) + kt ........(2)

^{−kt}......(1)C (t) = C (0) + kt ........(2)

The difference between the two is that the second order fits the linear equation meaning that the concentration changes uniformly with time.

The first order equation on the other hand should be exponential and the Matlab graph should show this clearly if it is exponential.

Finally to estimate the value of k you have to analyse the graph. If it is linear then it is second order with k being the slope of the line. If it is exponential however the you will have to do another step in Matlab. We basically Log everything in equation (1) using Natural Logs (Ln)

Therefore: ln C (t) = ln [C (0)e−kt]

Based on log rules ln[ab] = ln a + ln b

Thus it becomes: ln C (t) = ln C (0) + ln [e

^{−kt}]Remember ln e

^{x}= x which makes ln [e−kt] = -ktSo we end up with ln C (t) = ln C (0) - kt

Hence if you plot ln C vs t and you get a straight line then the slope is -k

Remember C(0) is your initial concentration which you can get at t=0 (ie 0.100).

So your Matlab becomes:

t = 0, 50, 100, 200, 300;

C = 0.100, 0.0079, 0.0065, 0.0048, 0.0038;

C = 0.100, 0.0079, 0.0065, 0.0048, 0.0038;

R = ln (C) %R is just a variable. You can use anything you like once it doesn't replace another variable or %conflict with built in variables like sin or log

plot(t,C)

plot(t,C)

Plot (t, R)

grid on % Turn on grid lines for this plot

%Remember you only need to do the second plot if it is first order as determined from the first plot. If it is second order then yo will get a straight line.