Storing array of values from for loop

Hi, I am analysing mass vs. time data sets. I have created a for loop to crop my data set and convert the mass to volume. I would like to store the information after each run. My aim is to plot all runs on a single graph at the end. Any help would be greatly appreciated.
for run=1:5;
%Load data
data=table2array(readtable(strcat('F:\ethanol\', num2str(run),'\mass',num2str(run),'.csv')));
time=data(:,1);
mass=data(:,2);
%Crop Data
startindex=find(mass == max(mass),1,'first');
time=time(startindex:end,:)-time(startindex);
mass=mass(startindex:end,:);
%Convert mass to volume
rho=785;
vol=mass*10^(-3)/rho*10^9;%microL
volmean=movmean(vol,200);
%Data to store
results(:,run)=[time(run) volmean(run)];
end

回答 (1 件)

VBBV
VBBV 2022 年 11 月 10 日

0 投票

results(:,run)=[time(run); volmean(run)]; % change
plot(results) % after for loop

2 件のコメント

Olivia
Olivia 2022 年 11 月 10 日
I should have clarified. The problem is with the results output which is being cropped to the number of values corresponding to the run number. I am unsure how to solve this.
VBBV
VBBV 2022 年 11 月 10 日
Can you tell what being cropped to number of values means more clearly ?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

2022 年 11 月 10 日

コメント済み:

2022 年 11 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by