write a matlab code and plot c vs t
Show older comments
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
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)
Answers (1)
Walter Roberson
on 20 Nov 2015
0 votes
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
Walter Roberson
on 20 Nov 2015
You have
t=[0:2000:16000]
That is length 9. You construct your y matrix as being 10 columns and fill up to column length(t) which is column 9. You then try to plot(t,y) so you are trying to plot a vector of length 9 against a matrix which is 4 by 10. That is a mismatch in size, so the plot is going to fail.
aman shrivastava
on 20 Nov 2015
Walter Roberson
on 20 Nov 2015
Why is the second parameter of that zeros() call 10? Is your time vector of length 10? Is your temperature vector of length 10?
aman shrivastava
on 20 Nov 2015
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 ?
Categories
Find more on MATLAB 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!