write a matlab code and plot c vs t

5 views (last 30 days)
aman shrivastava
aman shrivastava on 20 Nov 2015
Commented: SUBHOJIT BHOWMICK on 14 Aug 2018
i have to solve an equation given:
c=c0-exp(-k*t)/2
given
c0=1;
k=A*exp(-E/R/T)......(arrhenius equation) where T is temperature and t is time.
E=40,000
R=8.314
range of temperature can be taken from 25 to 400 (celsius)
range of time 2000 to 16000 hours
can anyone help me give me the code of this equation....please in a hurry.
[Merged from duplicate question]
here is the code that i wrote can anyone tell me what is wrong here:
  1 Comment
SUBHOJIT BHOWMICK
SUBHOJIT BHOWMICK on 14 Aug 2018
e=40000; r=8.314; c0=1; b=10; [x,y]=meshgrid (2000:1000:16000,25:20:400); c=c0-(exp(-(a.*exp(-e./r.*y.^2).*x)/.2)); surf(x,y,c)

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Nov 2015
Assign to the constants, c0, E, R, and A.
Then for any given combination of t and T, assign the correct formula to k. Now that you have the value for k, assign the correct formula for c.
There are a number of different ways to handle plotting for all the combinations of t and T. for loops; anonymous functions; arrayfun; bsxfun; meshgrid; ndgrid . Since this is homework, you will need to take the next step rather than us doing it for you.
  5 Comments
aman shrivastava
aman shrivastava on 20 Nov 2015
see i have uploaded the code you please see there and tell me where am i going wrong..?
Walter Roberson
Walter Roberson on 20 Nov 2015
Your code has
y=zeros(length(T),10)
that makes y have 10 columns. Inside your for loop you assign to y(i,j) where you have
for j=1:length(T)
length(T) is 4, so the maximum j you use inside the loop is 4, so although you initialized zeros(4,10) you are going to only use up to column 4. Why did you assign 10 columns when you have 4 temperatures and 9 times ?

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!