MATLAB Answers

L
0

How do I plot the minimum and maximum temperatures for each depth? i.e. the min and max boundaries of this graph?

L
さんによって質問されました 2018 年 8 月 6 日
最新アクティビティ L
さんによって コメントされました 2018 年 8 月 6 日
I want to plot the minimum and maximum temperatures (i.e. the min and max boundaries of this graph).
I have tried using findpeaks, but have not had success.
%settings
conductivity=.0033; %W m-1 K-1
heat_capacity=671.8; %J kg-1K-1
density=1300; %kgm-1^3
diffusivity=conductivity/(heat_capacity*density);
synodic_period=2.55e6; %seconds
synodic_frequency=(2*pi)/synodic_period;
T_av=250; %K
T_amp=150; %K
skin_depth=sqrt(2*diffusivity/synodic_frequency);
phase_dif=z*sqrt(synodic_frequency/(2*diffusivity));
t_list=linspace(0,synodic_period,25); %time frame over day (S_P)
z_list=linspace(0,.5,1000); %depth, starts at 0 goes to 1, 1000 steps
T=nan(length(t_list),length(z_list)); %output vector
for t_index=1:length(t_list)
t=t_list(t_index); %first timestep
for z_index=1:length(z_list)
z=z_list(z_index);
T(t_index,z_index)=T_av+T_amp*exp(-z*sqrt(synodic_frequency/(2*diffusivity)))*cos(synodic_frequency*t-z*sqrt(synodic_frequency/(2*diffusivity)));
end
end
plot(rot90(T), z_list)

  1 件のコメント

In this line, where you first use z, what is z?
phase_dif=z*sqrt(synodic_frequency/(2*diffusivity));
You have not defined z before you tried to use it.

サインイン to comment.

タグ

1 件の回答

回答者: jonas
2018 年 8 月 6 日
編集済み: jonas
2018 年 8 月 6 日

Assuming you have n series of T(d), each with data on m depths, just concatenate all your data in a m x n matrix and plot the max and min along n. For example:
%%10 series of data, 100 pts each
y=rand(100,10);
%%plot data
figure;hold on
plot(y)
%%plot max/min
plot(max(y,[],2),'linewidth',3)
plot(min(y,[],2),'linewidth',3)

  3 件のコメント

L
2018 年 8 月 6 日
Thank you for your response. I ended up doing the following:
max_T=[];
for i=1:size(T,2)
max_T(i)=max(T(:,i));
end
jonas
2018 年 8 月 6 日
That is basically the same but slower, especially when you don't preallocate your variables :)
L
2018 年 8 月 6 日
Oh, thank you! This is my first time using Matlab, so I appreciate the help!

サインイン to comment.



Translated by