Task : There are two Excel files, one contains the sample number and the time of sampling while the other contains the analysis results of each sample. Because the samples were taken in a chronicle order and were analysed in random order, it is kind of time consuming to manually find out each sample's result and put them into one file, especially when dealing with thousands of samples.
Here's a short code I wrote to do this:
% This program search the bag numbers and put the corresponding
% concentration values into the data file.
%% initialization
clear all;
clc;
%% import data
dataf=dataset('xlsfile','back.xls'); %aisle files from field test
concf=dataset('xlsfile','concentration.xls'); %concentration readings from autoTrac
%% determine dataset array size
datafL=length(dataf);
concfL=length(concf);
%% search and match
for i=1 : datafL
for j= 1 : concfL-1
if ( char(dataf.BagNumber(i))==char(concf.BagNumber(j)) )
dataf.Concentration1(i)=concf.Concentration(j);
dataf.Concentration2(i)=concf.Concentration(j+1);
break
end
end
end
%% Output data
export(dataf, 'xlsfile', 'Processed bag files-back.xls')
The dataset array is very power at handling different type of data, including numbers, strings, and even matrix.
To write a dataset array to an Excel file, I need to use export function instead of xlswrite.
MATLAB applications, tutorials, examples, tricks, resources,...and a little bit of everything I learned ...
Subscribe to:
Post Comments (Atom)
my-alpine and docker-compose.yml
``` version: '1' services: man: build: . image: my-alpine:latest ``` Dockerfile: ``` FROM alpine:latest ENV PYTH...
-
It took me a while to figure out how to insert a space in Mathtype equations. This is especially useful when you write an equation with mult...
-
Recently I read post from Dr. Doug Hull's blog: http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-s...
-
To get the slope of a pair of x and y, usually I first plot the curve and then add the trend line. Actually there are two functions i...
No comments:
Post a Comment
Any comments?