*Function for increasing density and thickness with depth

5 ビュー (過去 30 日間)
Tom Edwards
Tom Edwards 2020 年 10 月 27 日
I'm trying to make a function that creates a profile of randomised values (within a range) corresponding to increasing density and thickness of a body with depth. I have a 600 x 2 array with the first column indicating depth (0-600) and the second density (250-900). I've made the first part of my function, implemented the randomisation over a range but now I want to add some functionality wherby as we cycle through each successive row (depth) we select multiple adjacent rows that also get randomised values. So effectively, as we go deeper we select an increasing number of rows for randomisation of density values giving the impression of thicker areas layers being selected. The grpah should look something like I've plotted below but with layers of increasing thickness as we go deeper. I've added what I wrote so far below. I know its probably not efficient so any reccomendations for improving it are welcome.
Base = DP_1989{1:1200,2};
Diff = zeros(1000,1);
for i = 1:length(Base)
Diff(i) = 917 - Base(i);
% Pick a random number that generates a random number of ice lenses
rl = round(100.*rand(1,1));
% Index positions for each lens (number between 10:1000)
index = round((1000-10).*rand(rl,1) + 10);
% empty array for new density values
new_density = zeros(1200,1);
% Generate new density values
for i = 1:rl
new_density(index(i)) = (917-Base(index(i))).*rand(1,1) + Base(index(i)) ;
% Store them somewhere
for i = 1:rl
Base(index(i),2) = new_density(index(i));
%Convert original density profile from table to an array
DPtab = table2array(DP_1989(:,(1:2)));
%Insert new density values
for i = 1:rl
DPtab(index(i),2) = Base(index(i),2);
% Convert back to table, plot
DP_new = array2table(DPtab);
x2 = DP_new{:,2};
y2 = DP_new{:,1};
ylim([0 100])
xlabel('Density(kg m^{⁻3})');
set(gca, 'YDir','reverse') % Reverses direction of axis so surface is top of y axis

回答 (0 件)


Help Center および File ExchangeNewton-Raphson Method についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by