graph (some basic)

8 次查看(过去 30 天)
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