graph (some basic)

9 Ansichten (letzte 30 Tage)
Nishaben Desai
Nishaben Desai am 19 Mai 2020
Kommentiert: Nishaben Desai am 20 Mai 2020
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 Kommentare
Nishaben Desai
Nishaben Desai am 20 Mai 2020
Bearbeitet: Walter Roberson am 20 Mai 2020
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 am 20 Mai 2020
Dear Walter, I would try what options you sent. My only problem happening is,, graph isnt showing any movement. its blank

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Mai 2020
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 Kommentare
Nishaben Desai
Nishaben Desai am 20 Mai 2020
Let me try and get back to you.. thanks you so so much.. indeed
Nishaben Desai
Nishaben Desai am 20 Mai 2020
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by