フィルターのクリア

Table Name in a loop

1 回表示 (過去 30 日間)
Davin
Davin 2015 年 6 月 22 日
コメント済み: Davin 2015 年 6 月 22 日
Hello,
I am struggling with this fairly simple loop.
I have an an array with years like the following :
2012
2012
2012
2013
2013
2014
2014
2015
In the loop i want to create a table for each year, but I am not able to do it in a proper way.
I did the following,
s = unique(array(:,1))
v = size(s,1)
for i = 1 :v
if certain conditions
TableName = sum all values in year concerned year.
end
end
So my question is very simple, how to make this TableName(should contain the year, for example Table2013) change to the year where the conditions is met. i tried to do something like
strcat('Table',num2str(array(i))) = sum all values in year concerned year.
This does not work at all.
Thank you very much
D

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 22 日
編集済み: Azzi Abdelmalek 2015 年 6 月 22 日
data=[ 2012 2
2012 6
2012 9
2013 1
2013 8
2014 9
2014 9
2015 9]
[ii,jj,kk]=unique(data(:,1))
out=[ii accumarray(kk,data(:,2))]
  1 件のコメント
Davin
Davin 2015 年 6 月 22 日
Hello Azzi,
Thanks for your answer. Even if it was not exactly what I wanted to know( my question was more how to have a changing table name in a loop), you answer gave me some kind of solution to my issue. Thanks again for the prompt response.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by