# Basic matlab help with plotting

1. Aug 4, 2011

### tomg10000

Hi,

I am trying to write a short matlab program that plots concentration vs distance (oxygen sag curve from two different bod sources in a river). I know the equation im using is:

C= Cs - [(kd*Mo)*(exp(-x*kr/u)-exp(-x*ka/u))/(Q*ka-kr)] - (Cs-Co)*exp(-x*ka/u) - [(kd*Mo)*(exp(-(x-L)*kr/u)-exp(-(x-L)*ka/u))/(Q*ka-kr)].

Its very long and im having trouble getting it to work in matlab form.
Can someone used to matlab give me some hints how to make this work?

I know how to execute a plot by plot(x,C) but the equation is giving me trouble.

Any help would be greatly appreciated.
Thanks.

2. Aug 4, 2011

### gb7nash

I'm going to assume everything in there except x is a constant. First, you have to specify what points you want to use for x. For example, you could do:

x = linspace(0,1,100)

In a nutshell, this defines x as 100 points between 0 and 1. After this, you can type:

C= Cs - [(kd*Mo)*(exp(-x*kr/u)-exp(-x*ka/u))/(Q*ka-kr)] - (Cs-Co)*exp(-x*ka/u) - [(kd*Mo)*(exp(-(x-L)*kr/u)-exp(-(x-L)*ka/u))/(Q*ka-kr)]

plot(x,C)

If that still doesn't work, I don't know. Without knowing what all of these letters are, it's close to impossible to debug what you're doing.

3. Aug 5, 2011

### tomg10000

thanks, i got it working, just needed to correct some bracketing.