Help creating a for loop for research purposes
Mostrar comentarios más antiguos
Attached is the data I am using. Each frame is seperated by 1340 cells. I have some code to do what I want for one frame but I am struggling on how to expand this to a for loop to do the same thing for all 60 frames.
%Workspace must be cleared before using this script
clear
clc
%Input the folder location containing data that is being analyzed
MainFolder = 'C:\Users\nefwa\Documents\AcetoneResearch\07_16_2020_TempCheck';
cd(MainFolder)
rawdatafile = dir('*.csv');
rawdata = rawdatafile.name;
RawDataMatrix = csvread(rawdata, 1,0);
%Creates Rawdata folder in MainFolder
mkdir('Rawdata')
cd('Rawdata')
%Converting .csv file to .dat file
[~,fnm] = fileparts(rawdata);
rawdat = sprintf('%s.dat',fnm);
dlmwrite(rawdat, RawDataMatrix)
raw = '\Rawdata';
RawDir= strcat(MainFolder, raw);
%% Data
%Changes to first folder and then to Finaldata folder
cd(MainFolder)
cd('Rawdata')
%Searches for Acetone data
Tempfile = dir('*.dat');
Tempdata1 = Tempfile.name;
Tempdata = importdata(Tempdata1);
% N2 Main Peak Sum
N2peak = sum(Tempdata(436:461,3));
%N2 low rotational lines
N2low = sum(Tempdata(476:491,3));
%N2 high rotational lines
N2high = sum(Tempdata(520:610,3));
%H20 Main Peak Sum
H20peak = sum(Tempdata(1279:1303,3));
So in this code I am finding the sum of these peaks and rotational lines for one frame currently. I am hoping to expand this into a for loop to encompass all 60 frames I have (seperated by 1340 cells). I also would like to have each sum saved as like N2peak{1}, N2peak{2}, etc. Thank you in advanced for the help!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!