필터 지우기
필터 지우기

Question about graph data

조회 수: 1 (최근 30일)
Doug
Doug 2013년 4월 12일
I have a graph with temperature on the y axis against time on the x axis.
I was able to find the maximum point of temperature by using this function:
tmaxinner = max(u(:,1));
time along the bottom axis is given by variable 't'.
I would like to get the time value for when the temperature is at its maximum.
I thought something like this would work but it didnt:
timetaken = (t,max(u(:,1));
please can you help
many thanks

답변 (2개)

Leah
Leah 2013년 4월 12일
you just need the location of the maximum value.
[tmaxinner locmax]= max(u(:,1));
timetaken = t(locmax,1);
this would give you the first occurrence to the maximum value

Image Analyst
Image Analyst 2013년 4월 12일
Try this:
% Extract times from the 2D (badly-named) u.
times = u(:, 1); % Times are in the first column (I think).
% Extract temperatures from u.
temperatures = u(:, 2); % Temperatures are in the second column (I think).
% Find the max value of the temperatures
% and return the index of that location
[maxTemp, indexOfMaxTemp] = max(temperatures);
% Now we know the array index where the max temperature occurs.
% Get the time that that temperature happened by
% extracting the value of the times array at that same index
timeAtMaxTemperature = times(indexOfMaxTemp);
I hope the code is so well commented that it's basically self-explanatory. If it's not, just ask.
  댓글 수: 2
Doug
Doug 2013년 4월 13일
Thanks for your reply.
However the code you gave me unfortunately didn't work.
The code that I am writing is plotting the temperature change through a heat shield tile of a given thickness. The variable u holds the temperature data as it progresses through the tile. Here are the graphs that get plotted for the data u and t.
So this is the data that is produced by my code. t is a matrix given by [0:8:4000]. And u is colums of data in rows to correspond to the time data. The thickness of the material is given by the z axis which cannot be seen on the 2d plot.
What I am trying to find is the time at which the inner surface temperature is maximum which is represented by a blue line on the 2d plot.
Many thanks in advance
Image Analyst
Image Analyst 2013년 4월 13일
It was not clear from your original question what u was and where I could get the times and temperatures, so that's what I did. Are you saying that you can't make the simple adaptations to my code to get the times and temperatures from whatever variables you have?

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by