Hello,
I have a topographic data for three locations in a dataset called all_topo_data(46 by 8). I want to add another column(annual evaporation) into the dataset from a 3 dataset called annual_evaporation_kl, annual_evaporation_manila and annual_evaporation_bangkok which all the dataset contains only 1 by 1 matrix. I wanted to add the data according to variable called location in the all_topo_data dataset.
So..There will be a new column in all_topo_data called annual evaporation which will contains annual evaporation value according to locations.
Thank you

 採用された回答

Hugo
Hugo 2013 年 6 月 10 日

1 投票

I might not have understood your question, so please let me know if this does not answer it.
Suppose that you have a dataset A of size m x n and between the column 0<i<n and the following column you want to insert a column j from another dataset B. To do that, you just need to do the following
Anew = [ A(:,1:i) B(:,j) A(:,i+1:n)];
Does this solve your problem?
Best regards

4 件のコメント

Reyasudin
Reyasudin 2013 年 6 月 10 日
Thank you for your time Hugo,
But what I meant was to create a new column in a dataset and fill it with a values from other 3 datasets.
As an example,
I have a datasets called X that has 3 variables (A, B, C). I have one more dataset called Y that has 2 variables( D,E)
I want to create another column in dataset X and fill it with D and E according to values of A ( A is a categorical data). I hope you understand what I meant.
thanks, Reytech
Hugo
Hugo 2013 年 6 月 10 日
To add another column in X, you can just do
X=[X; zeros(size(X,1),1)];
Now, to fill the new column, if the data is in three different variables, as I interpret from your original message, you can do:
for ind=1:size(X,1) eval(['X(ind,4)=annual_evaporation_' X(ind,1) ';']); end
Assuming that X(:,1) contains text labels
Or
for ind=1:ind=1:size(X,1) X(ind,4)=Y(X(ind,1)); end
Assuming that X(:,1) contains numbers identifying each city, and Y has the values corresponding to each city.
Does this help?
Reyasudin
Reyasudin 2013 年 6 月 10 日
Thank you, although it does not solve my problem directly. You answer gave me an idea to solve it. Appreciate very much..
Boy
Boy 2016 年 4 月 12 日
Hi Hugo, i tried X=[X; zeros(size(X,1),1)]; and i got the following error Error using dataset/vertcat (line 31) All input arguments must be datasets. Any insight on that? Thank You

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Introduction to Installation and Licensing についてさらに検索

製品

質問済み:

2013 年 6 月 10 日

コメント済み:

Boy
2016 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by