import and read specific cell from multiple cvx files

5 ビュー (過去 30 日間)
Hafiz Muhammad Saqib Ashfaq
Hafiz Muhammad Saqib Ashfaq 2020 年 9 月 8 日
回答済み: TED MOSBY 2025 年 6 月 23 日
I have 115 cvx file having calibration data in it i want to store specific cell data from each file in one vector how can i do this?

回答 (1 件)

TED MOSBY
TED MOSBY 2025 年 6 月 23 日
Hi,
The general strategy will be:
Get a list of all .cvx files: Use dir to find all files with the .cvx extension in your specified folder.
Initialize an empty vector: This vector will store the extracted data from each file.
Loop through each file: For each .cvx file found:
  • Read the file into a MATLAB variable (matrix, table, or cell array).
  • Extract the specific cell data using indexing.
  • Append this data to your pre-initialized vector.
Below is an example :
filePattern = fullfile(folderPath, '*.cvx');
cvxFiles = dir(filePattern);
numFiles = length(cvxFiles);
extractedValues = zeros(numFiles, 1);
% Loop through each .cvx file
for i = 1:numFiles
fileName = cvxFiles(i).name;
fullFilePath = fullfile(folderPath, fileName);
dataTable = readtable(fullFilePath, 'FileType', 'text', 'Delimiter', ',', 'VariableNamingRule', 'preserve');
specificValue = dataTable{targetDataRow, targetCol};
extractedValues(i) = specificValue;
end
disp(extractedValues);
Hope this helps!

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by