Wednesday, December 19, 2012

Show the variable names of a dataset

list = get (dataset, 'VarNames')

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.

Friday, October 5, 2012

Matlab Statistic Tool Box regstats model trick

Just found this trick today.
When using:

regstats(y,x)

Matlab will use the linear model y=ax+b model to fit the data and calculate all relevant statistical parameters.

But sometimes we want to fix the trend line through zero, (0,0). In these case, this trick will help:

regstats(y,x,1)

Now Matlab will use the linear model y=ax model to fit the data and calculate all relevant statistical parameters.

Don't know why. But it is tested on R2010b version and confirmed by comparing with Excel calculation results.

Friday, September 7, 2012

batch processing multiple files in matlab using for loop and uigetfile function

Recently I got a bunch of files that have the same format and structure and I need to use Matlab to process each file, which means carrying out the same calculation procedure to each file. Here's the code I created to do this.

% Import the file names
% The {*.csv} parameter indicates that only csv files will be shown in the file selection window
% Turn on the MultiSelect parameter so that multiple files can be selected at the same time
[filename, ~,~]=uigetfile({*.csv}, 'MultiSelect', 'on');
% now use a for loop to carry out same calculation procedure to each file
% the process_each_file is a function that does the calculation procedure
% before using the for loop, let's define a space to store all the outputs from each file calculation first
Re=zeros(length(filename),1);
for i = 1 : length(filename)
     Re(i)=process_each_file ( filename(i))
end




Thursday, May 24, 2012

remove outliers in Matlab

Here's the code i wrote recently to remove the outliers from the experimental data. Anything outside the range from Q1-1.5IQR to Q3+1.5IQR will be removed.

a=[10 11 13 19 9 8 11 14 12 17 1 2 10 11 13 12 12 11 10];
IQR=iqr(a);
lowr=prctile(a,25)-1.5*IQR;
highr=prctile(a,75)+1.5*IQR;
new_a=a(a>lowr & a<highr);

Monday, February 27, 2012

Why would this happen???

When I copy and paste a date and time from one MS Excel file to another, the value was kept the same but after formatting it to the Time format, the date went almost 4 years back!!!


my-alpine and docker-compose.yml

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