声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: kleeblatt

[其他] 如何求幅值??

[复制链接]
 楼主| 发表于 2009-11-18 22:50 | 显示全部楼层
if i do it like this:
t=-N+1:N;
A=1.0;f=17.2;phi=40;
y=A*cos(2*pi*t*f/N+phi*pi/180);
everythings goes right.
but if i just want to use phase1,error jumps out:
??? Error using ==> times
Matrix dimensions must agree.
phase1 is <128*1 double>,shows here:
0
3,93396163586619
8,83046453180072
11,6311186638529
11,2852032132275
8,16429115438237
3,42142700284035
-2,00785915626561
-7,27003758417477
-10,9814095127588
-11,7693210235971
-9,50125290401178
-5,19827852519589
0,0755540599887536
5,52110483988927
9,96033284685893
11,8671678631308
10,5897860671053
6,85986574516244
1,83106201768410
-3,65438621341892
-8,62018703590539
-11,5601862248507
-11,3745054979715
-8,36678942985316
-3,68031853969484
1,73128196808665
7,02865158843185
10,8551703544759
11,8053382813413
9,67138766757273
5,44247874386262
0,199150317798624
-5,25906344418210
-9,78506215112777
-11,8459275005807
-10,7196707217138
-7,08425677046303
-2,09903232786475
3,38117109361063
8,40488708594418
11,4811148238893
11,4565288437530
8,56509172811930
3,93733854866132
-1,45468198789504
-6,78373271813096
-10,7214927023010
-11,8333425140581
-9,83622848517273
-5,68414033754368
-0,473112878088091
4,99493146583130
9,60350867104510
11,8163791138212
10,8431395116249
7,30529084768279
2,36564033520522
-3,10709203536907
-8,18474661381370
-11,3939737550963
-11,5311484142206
-8,75904829498166
-4,19239895590748
1,17818129656841
6,53549662248908
10,5805184253717
11,8532632418226
9,99561433953389
5,92315733116069
0,746239014363543
-4,72889980941472
-9,41586673610081
-11,7785245895997
-10,9600403119510
-7,52283744904273
-2,63080243663561
2,83230289230774
7,95998397314823
11,2988435253994
11,5982457374237
8,94850686170142
4,44540986626462
-0,901897207769072
-6,28415660713507
-10,4323983310435
-11,8650394268420
-10,1493841184832
-6,15942046354795
-1,01843680070663
4,46115450507246
9,22233591019281
11,7323769588005
11,0702242695693
7,73676255080719
2,89443515304596
-2,55695194856533
-7,73081845715696
-11,1958155393794
-11,6577092368834
-9,13331291839477
-4,69627928205803
0,625942508097649
6,02992315176618
10,2772917515210
11,8686198504245
10,2973770472697
6,39281707734105
1,28961663446127
-4,19187648975836
-9,02312039187059
-11,6779605360029
-11,1735463316539
-7,94692872442234
-3,15645477707631
2,28118197793132
7,49746969034869
11,0849918617198
11,7094346686512
9,31330999123343
4,94491285854079
-0,350425718110841
-5,77300349552364
-10,1153660200609
-11,8639634366244
-10,4394331578059
-6,62323103689094
-1,55969087316637
what's wrong:@Q
回复 支持 反对
分享到:

使用道具 举报

发表于 2009-11-18 23:50 | 显示全部楼层

回复8楼kleeblatt 的贴子

用下程序即可;
你的数据用逗号作小数点,将","    改为  "."      (这点可能不必改)
phase1  改为 phase1'  将列数据改为行数据

close all;clc;clear all;
N=64;
phase1=[0
3.93396163586619
8.83046453180072
11.6311186638529
11.2852032132275
8.16429115438237
3.42142700284035
-2.00785915626561
-7.27003758417477
-10.9814095127588
-11.7693210235971
-9.50125290401178
-5.19827852519589
0.0755540599887536
5.52110483988927
9.96033284685893
11.8671678631308
10.5897860671053
6.85986574516244
1.83106201768410
-3.65438621341892
-8.62018703590539
-11.5601862248507
-11.3745054979715
-8.36678942985316
-3.68031853969484
1.73128196808665
7.02865158843185
10.8551703544759
11.8053382813413
9.67138766757273
5.44247874386262
0.199150317798624
-5.25906344418210
-9.78506215112777
-11.8459275005807
-10.7196707217138
-7.08425677046303
-2.09903232786475
3.38117109361063
8.40488708594418
11.4811148238893
11.4565288437530
8.56509172811930
3.93733854866132
-1.45468198789504
-6.78373271813096
-10.7214927023010
-11.8333425140581
-9.83622848517273
-5.68414033754368
-0.473112878088091
4.99493146583130
9.60350867104510
11.8163791138212
10.8431395116249
7.30529084768279
2.36564033520522
-3.10709203536907
-8.18474661381370
-11.3939737550963
-11.5311484142206
-8.75904829498166
-4.19239895590748
1.17818129656841
6.53549662248908
10.5805184253717
11.8532632418226
9.99561433953389
5.92315733116069
0.746239014363543
-4.72889980941472
-9.41586673610081
-11.7785245895997
-10.9600403119510
-7.52283744904273
-2.63080243663561
2.83230289230774
7.95998397314823
11.2988435253994
11.5982457374237
8.94850686170142
4.44540986626462
-0.901897207769072
-6.28415660713507
-10.4323983310435
-11.8650394268420
-10.1493841184832
-6.15942046354795
-1.01843680070663
4.46115450507246
9.22233591019281
11.7323769588005
11.0702242695693
7.73676255080719
2.89443515304596
-2.55695194856533
-7.73081845715696
-11.1958155393794
-11.6577092368834
-9.13331291839477
-4.69627928205803
0.625942508097649
6.02992315176618
10.2772917515210
11.8686198504245
10.2973770472697
6.39281707734105
1.28961663446127
-4.19187648975836
-9.02312039187059
-11.6779605360029
-11.1735463316539
-7.94692872442234
-3.15645477707631
2.28118197793132
7.49746969034869
11.0849918617198
11.7094346686512
9.31330999123343
4.94491285854079
-0.350425718110841
-5.77300349552364
-10.1153660200609
-11.8639634366244
-10.4394331578059
-6.62323103689094
];
y=phase1';
y1 = y(N:2*N-1);
win =  hanning(N)';;
win1 = win/sum(win);
y11= y1.*win1;
y11_fft = fft(y11,N);
y1_amplitude = abs(y11_fft);
y2 = y(1:2*N-1);
win =hanning(N)';;
winn =conv(win,win);%apFFT
win2 = winn/sum(winn);
y22= y2.*win2;
y222=y22(N:end)+[0 y22(1:N-1)];
y2_fft = fft(y222,N);
a2 = abs(y2_fft);
aa=(y1_amplitude.^2)./a2*2;
[A,r]=max(a2(1:N/2));
aaa=aa(r)

运行结果
aaa = 11.6713

你绐的数据的是余弦信号,振幅是11.67,频率5.0394,中间点相位248.2883. 可用下式产生
t=-63:63;
A=11.6713;f=5.0394;phi=248.2883;
y1=A*cos(2*pi*t*f/64+phi*pi/180);
y1和你的数据基本吻合.

误差原因是你的信号中含有3次谐波和5次谐波成份
各次谐波频率为(Hz),振幅和中间点相位为
fm =      5.0394       15.1184          25.1853
Am =   11.6713         0.2260            0.0011
Pm = 248.2883       55.2875        260.0685

[ 本帖最后由 zhwang554 于 2009-11-19 06:27 编辑 ]
 楼主| 发表于 2009-11-19 00:25 | 显示全部楼层
Great!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
endlich es geht!!!! thank u soooooooooooooooooooooooooooooooooo much!!!!:kiss: :kiss:
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-14 17:05 , Processed in 0.056775 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表