Question about graph data
1 view (last 30 days)
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
Leah on 12 Apr 2013
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 on 12 Apr 2013
% 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.