2014年12月31日星期三

telemedicine

When I start to use RF module, I always hate it.
and this is the only project which I make the mistake more than twice.

how i make the mistake?

I use a trasmitter as receiver, and treat a receiver as transmitter....

wakaka.

i am the biggest idiot, but when I fix it , i feel like i am the happiest person in the world.

hope this is the last time I make the mistake.

thanks all the blessing.

2014年12月17日星期三

matlab journey 1

在我今晚睡觉前,我一定要把matlab code 写出来。
http://zhidao.baidu.com/question/88374307.html
strcat([name num2str(i)])不太懂
连接字符串的函数。。。楼主写的命令意思是把变量名为name的字符串与数字'i'连接。。。
例如若名字name='楼主';
当i=3时,函数就输出 楼主3
具体可以参考matlab的help文件
a = 'hello '
b = 'goodbye'
strcat(a, b)
ans =
hellogoodbye
另外提醒一下,num2str意思是把数字转为字符串

matlab中inline是什么,有什么作用
那么什么函数都能定义吗?非线性函数也可以定义吗?比如cos(x)
就是定义一个内置函数,本质上说跟function干的是一样的事,只不过它可以直接内嵌在命令行里,不用另外单独定义function.
想定义什么都可以。
g = inline('t^2')
g = inline('sin(2*pi*f + theta)')
g = inline('sin(2*pi*f + theta)', 'f', 'theta')

————————————————————————————————————————————————————————————————————————————————————
nargin是用来判断输入变量个数的函数,这样就可以针对不同的情况执行不同的功能。通常可以用他来设定一些默认值,如下面的函数。

例子,函数test1的功能是输出a和b的和。如果只输入一个变量,则认为另一个变量为0,如果两个变量都没有输入,则默认两者均为0。

function y=test1(a,b)
if nargin==0
a=0;b=0;
elseif nargin==1
b=0;
end
y=a+b;
————————————————————————————————————————————————————————————————————————————————————————————————————


















vectorize是什么?

vectorize 是向量化的意思

可以将字符串或者inline函数里面的运算变为向量运算

一般我们定义一个函数,或者用一个表达式去计算的时候
我们可以很自然地用编程语言去写出表达式,例如

y=x*(x+1)^2/(x+2)
只要x是一个数值,那么运行上面的语句y的值就和会被计算出来

>> x=1
x =
1

>> y=x*(x+1)^2/(x+2)
y =
1.3333

很多时候我们需要的不仅仅是一点的函数值,而是需要很多点的函数值
例如我们要画出函数图像,我们知道x在一定取值范围内很多点的函数值y
在别的语言里我们就需要用循环来计算
而由于matlab语言是矩阵运算语言,所以有时一条语句就代替普通语言的很多循环操作

x=-1:0.1:1;
y=x.*(x+1).^2./(x+2);
就这样两条语句,就计算了x从-1到1以0.1为间隔的21个点对应的y值
得到的结果y是和x大小相同的向量

这里注意表达式中的*^/三个运算符号前面都加了点
这是因为*^/在matlab里面定义的都是矩阵运算,是矩阵的乘、乘方、除
而我们这里要计算的是向量x里面每一个元素对应的计算结果,不是矩阵乘除
这里的乘、乘方、除要有.* .^ ./ 表示
这是初学matlab经常容易出错的地方
对于标量,也就是只有一个值的量例如上边的x=1
加点和不加点的两种表达式是等价的

而这个将原来只能用于标量的表达式,变为可以用于向量的表达式
也就是这个给*^/加点的过程,就是向量化过程,也就是vectorize函数的主要功能



when you study a series frame of MRI images ,
我在读取一批名如gh1_3.75a1.jpg,gh1_3.75a2.jpg,gh1_3.75a2.jpg,。。。图片时:
I=cell(1,50);
for i=1:10
imageName=strcat('gh1_3.75a',num2str(i),'.jpg');
I{i}=rgb2gray(imread(imageName));
figure;
imshow(I{i});
end

2014年12月15日星期一

contour matlab

[c,h] = contour(u,[0 0],'r')
请问上面代码是什么意思?我查过了没查到。应该是初始轮廓吧!


u是z轴数据所满足的条件,即z轴的数据;[0,0]表示画一条高度为0的等高线,如果想画高度为i 的等高线,改为[i,i],‘r’表示线条用红色显示。
C是等值线矩阵

What is the meaning of this code Img=double(Img(:,:,1))
img(:,:,1) selects the first "pane" of the array "img". If the array only has one pane (e.g., a grayscale image) then that portion is redundant but correct; if the array has multiple panes (e.g., an RGB image), it selects the first of them (probably the Red pane.)

double() indicates that the number values of the input should be examined and a new array the same size be constructed which has the same numeric values but represented as double precision data types. When applied to an image, the implication is most often (but not always!) that the original image array was stored as unsigned 8 bit integers, and now the floating point equivalent is desired. For example, converting an 8 bit integer with value "3" to its floating point equivalent, "3.0". There are various good reasons to do this kind of data type conversion; one of the several common reasons is to be able to do image subtraction and have results come out negative if appropriate (unsigned 8 bit integer subtraction cannot produce negative results and uses 0 where the results would be negative.)
http://www.mathworks.com/matlabcentral/answers/44235-matlab-code-what-is-the-meaning-of-img-double-img-1

2014年11月17日星期一

When I create a circular pattern the original features i patterned disappears, how to fix it?

Today doing the pattern circulation, do not work, so I went to website to look for clues , find two approach.

1. When I create a circular pattern the original features i patterned disappears, what is causing this?
https://forum.solidworks.com/thread/42537
The expert suggest to It is in feature mode, I just went ahead and used the circular patterns in my sketchs, thanks.


2. The holes show up in the preview function while creating the pattern, but disappear as you complete the pattern.
the expert also suggest use in feature mode, but here is the part I dont understand though
http://www.eng-tips.com/viewthread.cfm?qid=247760
The problem you're seeing is due to the fact that the original Hole Wizard feature you created just shows the original component it cut in the Feature scope for components affected by the Hole Feature. When the feature is circular patterned the pattern feature gives no option for additional parts to intersect. To fix the issue modify your Hole Wizard Assembly feature to include any components that you want to cut when patterning the Assembly feature.

The original Hole won't cut the other components but when it's patterned the holes will appear in any components selected in the Feature Scope Group box. These components must be selected manually in the original feature see attached file.

2014年11月15日星期六

maths in solidworks

lol, today using solidwork to draw a stent using wrap function,

it end up myone has a small gap in between, it shows the advantage of using divide operator, as it always leave the decimal place.
http://solidjott.com/does-anyone-know-if-there-is-a-way-to-cr/2009/05/13/

maths not good enough

2014年10月22日星期三

Periodic boundy condition code

ok, as I promise to solve the periodic condition problem for one of my collegues, so i decide give it a try.
http://www.cfd-online.com/Forums/fluent/28770-periodic-boundary-condition-shadow-pairs.html

use TUI: mesh/modify-zones/make-periodic choose your periodic boundary IDs as the input. Everything should go well and complete cells match on both sides should be found.

2014年10月19日星期日

difference between fourier transform and wavelets

Haiz, sometimes when all the hope fade, you have to look for something which can cheers you up.
anyway, you still have to live for quite a long time.

so i move out the first step for digital signal processing
http://math.stackexchange.com/questions/279980/difference-between-fourier-transform-and-wavelets
et us say we are looking at the signal of the light emitted from a traffic light. So for some time it will be red, and for some time it will be green (ignore the yellow for now). If we take the Fourier transform of the observed frequency, we can say that

At some time the traffic light shows red. (We know frequency to infinite precision, and that the red part of the signal is non-zero.)
At some time the traffic light shows green.
But a functioning traffic light would have either red or green shown at a time, and not both. And if the traffic light malfunctions and shows both lights at the same time, we would still see from the Fourier transform

At some time the traffic light shows red.
At some time the traffic light shows green.
But if we take the wavelet transform we can sacrifice frequency precision to gain temporal information. So with the wavelet transform done on the working traffic light we may see

At parameter w which corresponds roughly to t(w) being 1 o'clock sharp and k(w) corresponding to red, the wavelet transform is large and non-zero. This can be taken to mean that sometime around 1 o'clock sharp (could be exactly 1 o'clock, could be 1 minute past, could be 30 second before) the light showed a color that is more or less red (could be a little bit purple, or maybe a little bit amber).
At parameter w which corresponds roughly to t(w) being 1 o'clock sharp and k(w) corresponding to green, the wavelet transform is almost zero. This can be taken to mean that at all the times around 1 o'clock (say plus or minus 2 minutes) the traffic light does not show any hint of green.
At parameter w which corresponds roughly to t(w) being five minutes past 1 and k(w) corresponding to green, the wavelet transform is large and non-zero. This would indicate that around 1:05 (maybe 1:06, or 1:04) the light shined greenish (could have a tinge of teal or a bit of yellow in it).
This would tell us that not only can the traffic light show both red and green lights, that at least at around 1 o'clock the light is working properly and only showing one light.