Plot a time-depth temperature contour graph

21 ビュー (過去 30 日間)
Louis van Herwijnen
Louis van Herwijnen 2017 年 11 月 18 日
コメント済み: Walter Roberson 2022 年 7 月 20 日
Hi guys,
This is my first time using Matlab ever, so as you can imagine I am a bit lost.
I have to plot a contour graph with time as x, depth as y and temperatures as z. The data looks like this on excel :
I looked for tutorials on Internet but I am completely lost. Could someone please give me some hints as to where to start, for example only how to make the data useable on Matlab ? I tried the 'xlsread' command but I have no idea what to do next... any king of help would be great ! Thank you !
[Merged from essentially same question]
Hi guys,
So I have this data and I am trying to plot a contour graph with : depth as Y, the hours as X, and the temperature as the data assigned to each depth and hour. But whatever I try, I have something that does not work, be it matrix dimension or something else. I do not understand how I should define each variable, X Y Z, when it shouldn't be too complicated ! does anyone have any kind of hints or help ? The blanks are simply times when the temperature could not be recorded, but that shouldn't be a problem in a contour plot should it ?? I am getting really desperate
  3 件のコメント
Louis van Herwijnen
Louis van Herwijnen 2017 年 11 月 18 日
No these are blank because the tide was rising : measurements could not always be carried out at those depths, so there is just no data at some times ! (which is also part of why I'm having trouble)
Louis van Herwijnen
Louis van Herwijnen 2017 年 11 月 18 日
So depth is the first line, time is the first column and everything else are temperature readings

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 18 日
data = xlsread('Plots.xls');
time_in_days = data(1,2:end);
depth = data(2:end,1);
temperature = data(2:end,2:end);
contourf(time_in_days, depth, temperature)
datetick('x', 'HH:MM')
  1 件のコメント
Louis van Herwijnen
Louis van Herwijnen 2017 年 11 月 19 日
Mr Roberson, you saved my life !! thank you !!!

サインインしてコメントする。

その他の回答 (1 件)

Ruben
Ruben 2022 年 7 月 15 日
編集済み: Ruben 2022 年 7 月 18 日
Hi @Walter Roberson or anyone else who could help. I have a very similar problem. My imported data looks like this:
Is the Var1 column a datetime? I use the code below and get this error:
"Error using contourf
Input arguments must be numeric or objects which can be converted to double."
I've tried turning the datetime into a number with datenum (commented out below) but I haven't had success with that either. It gives the error:
"Error using datenum
DATENUM failed.
Caused by:
Error using datevec
The input to DATEVEC was not an array of character vectors or strings."
%% Import Data
filename = "Plots_mmddyyyy.dat";
A = readtable(filename);
Aopts = detectImportOptions(filename);
%% Partition Table Data Into Variables
Depth = A(1,2:end);
Time = A(2:end,1);
Temperature = A(2:end,2:end);
%Ttime = datenum(Time);
%% Plot
contourf(Time,Depth,Temperature)
  6 件のコメント
Ruben
Ruben 2022 年 7 月 19 日
編集済み: Ruben 2022 年 7 月 19 日
I got an error message again. Same error message as before. Do you have any other suggestions? Thank you for your time!
Walter Roberson
Walter Roberson 2022 年 7 月 20 日
%% Import Data
filename = "Plots_mmddyyyy.dat";
Aopts = detectImportOptions(filename);
A = readtable(filename, Aopts);
%% Partition Table Data Into Variables
Depth = A{1,2:end};
Time = A{2:end,1};
Temperature = A{2:end,2:end};
%% Plot
contourf(datenum(Time), Depth, Temperature)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by