graph (some basic)

조회 수: 3 (최근 30일)
Nishaben Desai
Nishaben Desai 2020년 5월 19일
댓글: Nishaben Desai 2020년 5월 20일
I wanna know if we wish to plot graph and its based on some equations result, of for example Temperature vs time.. and the values I wish to have on X as (t:dt:tend) and this values are inputs..to draw graph for y axis as calculated value of Temperature..
I am trying this way
x = [t : dt: tend];
y = Tn;
figure
plot(x, y, 'r')
But I am not getting the result; because I learned that y got to be the function of x, but I dont know what to use as if u use f(x) its not accepting here, so what else I can do
  댓글 수: 4
Nishaben Desai
Nishaben Desai 2020년 5월 20일
편집: Walter Roberson 2020년 5월 20일
Geoff,
Tn is the Temperature, and it is variable, but I know it still isnt right one here is how it looks like, the entire codes look like this
prompt = 'What is the value of Area, A? ';
A = input(prompt)
prompt = 'What is the value of Heat Transfer Coefficient, h? ';
h = input(prompt)
prompt = 'What is the value of Temperature of System, Ts? ';
Ts = input(prompt)
prompt = 'What is the value of Temperature of Surroundings, Tf? ';
Tf = input(prompt)
prompt = 'What is the value of mass, m? ';
m = input(prompt)
prompt = 'What is the value of Heat Capacity, c? ';
c = input(prompt)
prompt = 'What is the value of time interval, dt? ';
dt = input(prompt)
prompt = 'What is the value of time at the end, tend? ';
tend = input(prompt)
t = 0;
q2 = 150;
while t<tend
q1 = - A*h*(Ts - Tf)
Q = (q1+q2)*dt
Tn = (Q/(m*c)) + Ts
Ts = Tn;
t = t+dt;
end
I can also have option to plot graph of time t vs temperature Tn, where they can take direct value from the loop.; but it still doesnt seem working
Nishaben Desai
Nishaben Desai 2020년 5월 20일
Dear Walter, I would try what options you sent. My only problem happening is,, graph isnt showing any movement. its blank

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 20일
prompt = 'What is the value of Area, A? ';
A = input(prompt)
prompt = 'What is the value of Heat Transfer Coefficient, h? ';
h = input(prompt)
prompt = 'What is the value of Temperature of System, Ts? ';
Ts = input(prompt)
prompt = 'What is the value of Temperature of Surroundings, Tf? ';
Tf = input(prompt)
prompt = 'What is the value of mass, m? ';
m = input(prompt)
prompt = 'What is the value of Heat Capacity, c? ';
c = input(prompt)
prompt = 'What is the value of time interval, dt? ';
dt = input(prompt)
prompt = 'What is the value of time at the end, tend? ';
tend = input(prompt)
q2 = 150;
tvals = 0 : dt : tend;
num_t = length(tvals);
Tn = zeros(1, num_t);
for tidx = 1 : num_t
t = tvals(tidx);
q1 = - A*h*(Ts - Tf);
Q = (q1+q2)*dt;
Ts = (Q/(m*c)) + Ts;
Tn(tidx) = Ts;
end
plot(tvals, Tn);
  댓글 수: 2
Nishaben Desai
Nishaben Desai 2020년 5월 20일
Let me try and get back to you.. thanks you so so much.. indeed
Nishaben Desai
Nishaben Desai 2020년 5월 20일
yap. It looks awesome, I learned this now, of how to plot graph like this.
Tons and tons and tons of thanks for saving so much of my time. I been struggling and trying since last week.
Nisha

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by