フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I get a vector from a structure ? Having trouble pulling out out the vector of structure.

2 ビュー (過去 30 日間)
juan Ortiz
juan Ortiz 2019 年 4 月 4 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
% 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];

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 4 月 4 日
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.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by