write a matlab code and plot c vs t

조회 수: 6 (최근 30일)
aman shrivastava
aman shrivastava 2015년 11월 20일
댓글: SUBHOJIT BHOWMICK 2018년 8월 14일
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에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by