Borrar filtros
Borrar filtros

How can I use the struct function to struct my data set. And be able to perform a forloop . As show in my code

2 visualizaciones (últimos 30 días)
%% Loading Data
% using the excel data
[FileName, PathName] = uigetfile('*.xlsx','Select Excel files to analyze:','MultiSelect','off');
[status, sheets] = xlsfinfo([PathName, FileName]);
summary_data = xlsread([PathName, FileName],sheets{1});
Volume = summary_data(:,1); % in mL
Time = summary_data(:,2); % in Seconds
Power = summary_data(:,3); % in watts;
data = struct('volume',[],'time ',[],'power',[]);
% for j = 1:length(sheets)-1 ;
% rawdata = xlsread([PathName, FileName],sheets{j+1});
% data(j).volume = rawdata(:,1);
% data(j).time = rawdata(:,2);
% data(j).power= rawdata(:,3);

Respuestas (1)

Walter Roberson
Walter Roberson el 3 de Abr. de 2019
Editada: Walter Roberson el 4 de Abr. de 2019
%% Loading Data
% using the excel data
[FileName, PathName] = uigetfile('*.xlsx','Select Excel files to analyze:','MultiSelect','off');
[status, sheets] = xlsfinfo([PathName, FileName]);
summary_data = xlsread([PathName, FileName],sheets{1});
Volume = summary_data(:,1); % in mL
Time = summary_data(:,2); % in Seconds
Power = summary_data(:,3); % in watts;
numsheets = length(sheets);
data(numsheets-1) = struct('volume',[],'time ',[],'power',[]);
for j = 1:numsheets-1 ;
rawdata = xlsread([PathName, FileName],sheets{j+1});
data(j).volume = rawdata(:,1);
data(j).time = rawdata(:,2);
data(j).power= rawdata(:,3);
end

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by