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