Read different matrix into a loop

11 ビュー (過去 30 日間)
Iago Martinez Alonso
Iago Martinez Alonso 2021 年 5 月 17 日
回答済み: Tarunbir Gambhir 2021 年 5 月 24 日
Hi!
This is my first post and I hope that I am posting properly.
I have some temporal yearly data into .txt files for each year and in order to read it i made the following code:
for i=16:20
fileID=sprintf('data20%d.txt',i);
farrusa=readtable(fileID,opts);
full_data=[full_data;farrusa];
end
I've sorted all data by months and now I have twelve matrix called "monthData1","monthData2"...
Now, I want to do a loop similar in order to read those 12 matrix and make further calculations whithin a loop with the monthData%d option, but for 2D matrix array the sprintf funtcion does not work.
This is what I would like to do:
for i=1:12
values="FUNCTION"('monthData%d');
end
is there any function that makes that or I have to pass all the matrix to .txt files?
Thanks!

回答 (1 件)

Tarunbir Gambhir
Tarunbir Gambhir 2021 年 5 月 24 日
You can concat all the monthData matrices into a single matrix called monthData. Then you can use the following
for i=1:12
values="FUNCTION"(monthData(i,:));
end
Is this what you are trying to acheive?

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by