Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How can I get a vector from a structure ? Having trouble pulling out out the vector of structure.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
% 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 = 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);
end
% analyze the std, and mean
for j = 1: length(sheets)-1;
data(j).flowRate = (data(j).Volume/data(j).Time);
data(j).meanQ = mean(data(j).flowRate);
data(j).stdQ = std(data(j).flowRate);
end
%% pulling vector from structure
mean_flowRate = [data.meanQ];
std_flowRate = [data.stdQ];
% first graphsubplot(1,2,1);hold on, box on, axis squarefor
for j = 1:length(sheets)-1;
plot(data(j).Time,data(j).Volume,'o','MarkerEdgeColor','k','MarkerFaceColor',clrlist{j});
end
xlabel('Time [s]');
ylabel('Volume [mL]');
%% This is the error I keep getting !
Reference to non-existent field 'meanQ'.
Error in Lab1 (line 25)
mean_flowRate = [data.meanQ];
0 comentarios
Respuestas (1)
Walter Roberson
el 4 de Abr. de 2019
length(sheets) is 1, so length(sheets)-1 is 0, so your for j loops are not being executed, so no fields exist in the structure other than the ones you initialized to, volume, time, and power.
0 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!