首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

熟悉matlab的朋友请进解决办法

2012-05-03 
熟悉matlab的朋友请进下面是《小波与小波变换导论》62页计算Daubechies频域变换的代码,初学matlab,有些语法

熟悉matlab的朋友请进
下面是《小波与小波变换导论》62页计算Daubechies频域变换的代码,
初学matlab,有些语法不懂,请帮助解释一下:

function [hf,ht] = pf(h,kk) 
//h是Daubechies系数:[0.482962913144534,0.836516303737808,0.224143868042013,-0.129409522551260]
//kk调用参数是1、2、3、4之类。
% [hf,ht] = pf(h,kk) computes and plots hf, the Fourier transform
% of the scaling function phi(t) using the freq domain
% infinite product formulation with kk iterations from the scaling
% function coefficients h. Also calculates and plots ht = phi(t)
% using the inverse FFT csb 5/19/93 page62
if nargin==1, kk=8; end % Default iterations
L = 2^12; P = L; % Sets number of sample points
hp = fft(h,L); //这里是快速傅里叶变换,我想了解其过程,如何跟踪进去???
hf = hp; % Initializes iteratioplot(abs(hf));
pause(1); % Plots first iteration
for k = 1:kk % Iterations
  hp = [hp(1:2:L), hp(1:2:L)]; % Sample 如何理解这里[]夹两个值的语法? 是把向量hp用自身的偶数位填充吗?
  hf = hf.*hp/sqrt(2); % Product 这里.*语法如何理解,是两个向量相乘???
  plot(abs(hf(1:P/2))); % P/2
  pause(1); % Plot Phi(omega) each iteration
  P=P/2; % Scales axis for plot
end;
ht = real(ifft(hf)); % phi(t) from inverse FFT
ht = ht(1:8*2^kk); 
plot(ht(1:8*2^kk)); % Plot phi(t)如何理解如何理解

[解决办法]
1.matlab直接调用函数,知道怎么用,传什么参数,接什么返回值就行了,不需要了解过程。
2.hp(1:2:L):从1到L,步长为2。hp = [x,y]
3.A*B:为线性代数中定义的矩阵乘法。按乘法定义要求必须有矩阵A的列数等于矩阵B的行数.
A.*B:符号数组的乘法,为按参量A与B对应的分量进行相乘。A与B必须为同型阵列,或至少有一个为标量.
例子:
1)点乘表示两个矩阵对应位置元素相乘,都为2行3列。例如:
>> a = [1 2 3;2 3 4];
>> b = [1 2 3;2 3 4];
>> a.*b

ans =

1 4 9
4 9 16
>> c = [1 2 3;1 2 3;1 2 3];
>> a.*c
??? Error using ==> times
Matrix dimensions must agree.
(2)而乘 * ,这个和我们在数学中学到的矩阵相乘是一个意义。例如:
>> a*c

ans =

6 12 18
9 18 27
>> a*b
??? Error using ==> mtimes
Inner matrix dimensions must agree.
4.plot就是画点
假如t为向量,且维数为m,plot(t)等价于plot(x,t),其中x = 1:m

这是我自己的理解,可能有的地方不对
[解决办法]
hp = fft(h,L); //这里是快速傅里叶变换,我想了解其过程,如何跟踪进去???
--------------------------
matlab里help fft即可看到源文件

hp = [hp(1:2:L), hp(1:2:L)]; % Sample 如何理解这里[]夹两个值的语法? 是把向量hp用自身的偶数位填充吗?
----------------------------
这个就是向量拼接
你单步执行一下看看hp的变化就明白了

hf = hf.*hp/sqrt(2); % Product 这里.*语法如何理解,是两个向量相乘???
-----------------------------------------------------
是的
一般标量乘向量也用这个符号

plot(ht(1:8*2^kk)); % Plot phi(t)如何理解如何理解
----------------------------------
phi(t)是什么?
Plot就是描点绘图
[解决办法]
matlab底层的源代码是看不见的

热点排行