MATLAB applications, tutorials, examples, tricks, resources,...and a little bit of everything I learned ...
Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts
Wednesday, February 11, 2015
Wednesday, February 27, 2013
Set the properties of a dataset array in Matlab
The percent sign, %, can be used in the matlab code to add explanatory information to the code. Similarly, we can add explanatory information to a dataset array, by using the dataset array properties. The set function can be used to assign values to the dataset property, and the get function can be used to access these information.
DS=dataset(...) % a dataset array is constructed
DS=set(DS, 'Description', 'Whatever can describe the dataset can be put here');
get(DS) % show dataset array properties
summary(DS) % also show dataset array properties
The 'Description' can be replaced with other properties which are displayed by the get function.
Friday, February 22, 2013
Convert a dataset to matrix
For the simplest case when the dataset only contains numbers, this double function can be used to convert a dataset to matrix, or a vector if there is only one variable in the dataset:
m=double(ds)
m=double(ds)
Thursday, November 17, 2011
How to concatenate two datasets in Matlab?
I wanted to vertically combine two datasets, so I can keep a long file of all the test results. The join function does not work here anymore. Of course this is even not a problem in Excel. However, to make it work in Matlab, it did took me a while to figure it out.
c=cat(1, a, b)
Wednesday, June 1, 2011
simple data matching by using dataset arrays
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.
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.
Subscribe to:
Posts (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...
-
In this post, I am trying to solve the problem given in the comments of one of the old post. Here's the problem, if I understand it co...
-
Recently I got a very long column of data and it contains lots of NaN. I found the finite function very useful to help me remove all the NaN...