Numerical values into plot issue

조회 수: 1 (최근 30일)
Cameron Thames
Cameron Thames 2011년 11월 25일
I created a code that takes an initial guess for a distribution and then modifies it. After completing the code it then is supposed to plot the modified distribution, however it is plotting both the guess values and final values. My guess looks something like:
Tfuel = zeros(nr+1);
Tfuel(:) = 800;
The guess is then modified very much like the following statement:
Ttemp=0.5*dr*dr*(qvol/k+Tfuel(i+1)/(dr*dr)+Tfuel(i-1)/(dr*dr)+...
Tfuel(i+1)/(2*dr*dr*i)-Tfuel(i-1)/(2*dr*dr*i));
Ttemp=(1-w)*Tfuel(i)+w*Ttemp;
Tfuel(i)=Ttemp;
I used the basic plot command as:
plot(r,Tfuel)
Any idea why this is occurring? I have never had this issue before.
Thanks
  댓글 수: 1
karan
karan 2011년 11월 25일
use fplot as tfuel is still getting values as it is being used

댓글을 달려면 로그인하십시오.

채택된 답변

Wayne King
Wayne King 2011년 11월 25일
I suspect maybe you want
Tfuel = zeros(nr+1,1);
instead of
Tfuel = zeros(nr+1);
With the above you are creating a nr+1-by-nr+1 matrix and then with
Tfuel(:) = 800;
You are filling the whole matrix with 800. Then in your loop
Tfuel(1) % or whatever you index i is
You are only filling the first column.
  댓글 수: 1
Cameron Thames
Cameron Thames 2011년 11월 25일
That did the trick.
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

karan
karan 2011년 11월 25일
Use fplot

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by