Thursday, February 28, 2013

Matlab: Remove a cell element from a cell array

Similar to the method to remove unwanted element in a matrix, which is discussed in details in another post (http://matlabnewbie.blogspot.com/2009/07/matlab-remove-all-unwatned-elements-in.html), the unwanted cell element can be removed from a cell array. The only difference is that the strcmp function should be used to identify where all those unwanted cells are.

The following example shows how to remove the cell 'good' from the cell array a, to be somehow humble.

a=[{'this'},{'is'},{'a'},{'good'},{'matlab'},{'blog'}];                 % create a cell array
a=a(~strcmp(a, 'good'))                                                          % remove the 'good' cell

Result looks like this:


a = 

    'this'    'is'    'a'    'matlab'    'blog'

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)

Wednesday, January 9, 2013

Two useful Excel tricks

I was using Excel today and find that I need to do two things. The first one is to automatically alternate row colors (one shaded, one white), so I searched online and found this tutorial very useful.

http://www.techonthenet.com/excel/questions/cond_format2.php


And the other thing I would like to do is to create a list from data validation, so in each cell of one column, I can select the car makers. And I would like to use the next column to record the car model, which mean the second list is dependent on the selection of previous cell's input. I searched online and found that it is called : dependent list for data validation. Here's the tutorial that I followed:

http://www.contextures.com/xlDataVal02.html

Very helpful!

Saturday, November 24, 2012

Matlab surface fitting: why and how

Recently I come across a problem like this in my work:

Tow inputs, or say variables, determine the value of one output. z=f(x,y), but I am not sure what the function look like explicitly. So I did a lot of measurements and by the end I got three sets of data: 7 x values, 21 y values, and 147 corresponding z values. The surface fitting is the method that can help me find the explicit form of function z=f(x,y). And I used the Surface Fitting Tool in MATLAB to do this.

This tool has a very user-friendly interface, so not much explanation is needed here.
Screen shot of Surface Fitting Toll

Sunday, November 4, 2012

Link Exchange

This blog has ~5000 page views each month. I am more than happy to exchange links with you if you are the owner of a blog/website which focuses on the engineering, science, and technology.

Leave me a comment if you are interested and I will respond in a timely manner.

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...