フィルターのクリア

Create a different output for every document that is imported

1 回表示 (過去 30 日間)
flashpode
flashpode 2021 年 9 月 19 日
コメント済み: flashpode 2021 年 9 月 22 日
Hey, I got a function that imports all the text documents from a file and creates a variable with all of them. What I wanted is to get a variable for each document. Here is the code:
dades = [];
for i=0:1:23
%x=sprintf('%00d',i)
fname = '2021030100'+string(sprintf('%00d',i))+'AIS.txt';
temp = importfileAIS(fname)';
dades = [dades', temp]';
end
How could I do it. I know that all the files go to the same variable(dades) because I wrote it, but I do not know how to write what I asked.
  3 件のコメント
flashpode
flashpode 2021 年 9 月 19 日
Just columns. They have just 1 column
darova
darova 2021 年 9 月 19 日
編集済み: darova 2021 年 9 月 19 日
Why don't just create a matrix? Each column is a variable
dades = [dades temp(:)];

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

採用された回答

Harikrishnan Balachandran Nair
Harikrishnan Balachandran Nair 2021 年 9 月 22 日
Hi,
I understand that you are trying to read data from a file and store it in a variable. The 'importdata' function in matlab can be used to load the data from the text file into an array in matlab.
To store the data loaded from the file in each iteration , you can add each column that you have imported as the new column in your output matrix. If the loaded data in each iteration is of different sizes, you may store the data in a cell array. You can easily access the imported data by indexing the corresponding element.
If you must create a new variable in each iteration, you can use the 'eval' function. You can refer to the following similar answer to get a better idea on it.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by