1-D Temperature Gradient
이전 댓글 표시
Hey everyone,
I am trying to figure out how to draw a temperature gradient of a 1-D system. I have tried to understand meshgrid but I couldn't find a way out. Plus, I have tried to use contourf but still didn't work for me. I might be using these functions wrong.
I have 19 different points and all of those points have the same x-coordinate value, only their y-coordinate values change. For example, Point_1(0, 1), Point_2(0,2), Point_3(0,3)... Basically, they form a vertical line on a coordinate system. Also, I have corresponding temperatures for every point. I want to plot a temperature gradient looking like color bars standing next to graphs but I couldn't find a proper way to do that. Could any of you please help me out to understand how to do that?
댓글 수: 9
Image Analyst
2021년 5월 4일
"I have 19 different points" <=== well, what are they? You forgot to include them, so what can we do???
Kubilay Akpinar
2021년 5월 5일
J. Alex Lee
2021년 5월 5일
I guess you want a contour plot of temperature on a plane of x-position and time? so you need your temperatures at every x-node at a series of times...you didn't mention if you have that?
Kubilay Akpinar
2021년 5월 5일
J. Alex Lee
2021년 5월 5일
Based on your responses, it seems you were on the right track with using meshgrid() to "hang" your temperature data onto using something like contourf(). But to be more helpful, like Image Analyst says, need more details, ideally your data too. Is your temperature data in 10,000 different "lists" of 19 elements? Already in a matrix that is 19x10,000?
Kubilay Akpinar
2021년 5월 6일
Image Analyst
2021년 5월 8일
Not sure why you're refusing to attach your data though. Make it easy for people to help you, not hard.
Anyway, did you try the answer below?
Kubilay Akpinar
2021년 5월 8일
편집: Kubilay Akpinar
2021년 5월 8일
J. Alex Lee
2021년 5월 11일
what exactly is it about the result "which is not wrong" that isn't what you want?
답변 (1개)
J. Alex Lee
2021년 5월 7일
편집: J. Alex Lee
2021년 5월 7일
your time and space point vectors are
t = 0:0.005:50; % but this gives you 10,001 points, not 10,000...so you decide what you have
x = linspace(0,9,19); % just guessing based on your image
making up some temperature matrix with the dimensions you have
tmp = rand(1,numel(x),numel(t));
it is senseless to have your first dimension in your temperature data matrix, so need to squeeze out the first dimension
tmp_a = squeeze(tmp);
turns out you don't even need meshgrid because contourf will imply it for you (if you get the order of dimensions right)
contourf(t,x,tmp_a)
or if you want t and x transposed
contourf(x,t,transpose(tmp_a))
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


