insert an array according to the values from another variable

From the following example:
time = [733774,733774,733775,733775,733775,733776,733776];
bthD = [20,10,0,15,10,20,10];
bthA = (1000:100:1600);
%Hypsographic curve
Hypso = [(10:1:20)',(1000:100:2000)'];
d = [1,1.3,1,2.5,2.5,1,1.2];
data = horzcat(time',bthD',d');
[uniqueTimes,idx,idx] = unique(time);% finds the unique times and the index
counts = hist(time,uniqueTimes);% finds the distribution of uniqueTimes in time
expandedData = mat2cell(data,counts,length(uniqueTimes));
I would like to add another 'column' into expandedData which show the corresponding areas of the depths (expandedData{i}(:,2)). The area at each depth is given by the variable Hypso, which stands for hypsographic curve, so, the first column refers to the depths and the second column refers to areas. So, in this example I would like to go into each cell in expandedData and find the area for the corresponding depth from 'Hypso'. Hope this makes sense.

3 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 18 日
Are you sur the variable bthD and bthA correspond to the area and depth respectively? maby you mean bthA and bthD
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 18 日
this is another question. the first one was answered, if you want to ask another qustion, just repost annother one
Richard
Richard 2012 年 9 月 18 日
Ok, I always here people complaining about asking similar questions so I thought I'd avoid doing that.

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

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 18 日

0 投票

newD=[newD bthA(newD(:,2))]

3 件のコメント

Richard
Richard 2012 年 9 月 18 日
sorry I have now altered my original post, your solution worked great for the previous example but didn't work when I applied it to mine. The post now shows an example similar to my actual data.
José-Luis
José-Luis 2012 年 9 月 18 日
In the future, I would suggest accepting an answer and asking a new question, if your original question was adequately solved.
Richard
Richard 2012 年 9 月 18 日
thank you for your suggestion

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by