write a matlab code and plot c vs t

4 次查看(过去 30 天)
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 个评论
SUBHOJIT BHOWMICK
SUBHOJIT BHOWMICK 2018-8-14
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)

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-11-20
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 个评论
aman shrivastava
aman shrivastava 2015-11-20
see i have uploaded the code you please see there and tell me where am i going wrong..?
Walter Roberson
Walter Roberson 2015-11-20
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 ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by