Extract data from structure and change it to Numerical matrix

1 回表示 (過去 30 日間)
Ali Kareem
Ali Kareem 2016 年 4 月 28 日
回答済み: Azzi Abdelmalek 2016 年 4 月 28 日
Hi,
I have 100 .xlsx files. Each file has 100*100 (row*column).I used blow code to read them.
clear;
clc;
M= 100;
data = cell(1, M);
for k = 1:N
N= sprintf('Data%d.xlsx', k);
data{k} = importdata(N);
end
I have couples of questions
  • How can I plot each column starting from column number 2 against column number1 for all matrices? I should have 99 plot for each matrix.
  • How can I extract data from the structure to do some operation on it? I should have 100 matrices with size (100*100).
I tried below code to extract data, but it isn't working. it is saving only one matrix
for i=1:100
z=data{1,i}.data;
end
I tried this code to make 3D matrix. It will be easier for plotting but when I execute code I got two structures one inside each other and that make extracting data from it difficult
data=zeros(100,100,100)
M= 100;
for k = 1:M
N = sprintf('file%d.xlsx', k);
data(:,:,k)=importdata(N);
end
Thanks

採用された回答

Jan
Jan 2016 年 4 月 28 日
編集済み: Jan 2016 年 4 月 28 日
Combine your loops:
data = zeros(100,100,100)
M = 100;
for k = 1:M
FileName = sprintf('file%d.xlsx', k);
FileData = importdata(FileName);
data(:,:,k) = FileData.data;
end

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 28 日
M= 100;
data = cell(1, M);
for k = 1:N
N= sprintf('Data%d.xlsx', k);
data{k} = xlsread(N);
end

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by