声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 879|回复: 2

[编程技巧] 求助大虾!

[复制链接]
发表于 2006-10-14 10:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
本人写的一段信道差错概率与信道容量的小程序,在编译时出现错误提示:Subscript indices must either be real positive integers or logicals.出错的是H(p)=-sum(p.*log2(p)); 请哪位大虾指点迷津!不甚感激!程序如下:

echo on
gamma_db=[-20:0.1:20];
gamma=10.^(gamma_db./10);
p_error=1/2.*erfc(sqrt(gamma));
%capacity=1.-entropy2(p_error);
p=p_error;
H(p)=-sum(p.*log2(p));
capacity=1.-H(p);
pause % Press a key to see a plot of error probability vs. SNR/bit.
clf
semilogx(gamma,p_error)
xlabel('SNR/bit')
title('Error probability versus SNR/bit')
ylabel('Error Prob.')
pasue % Press a key to see a plot of channel capacity vs. SNR/bit.
clf
semilogx(gamma,capacity)
xlabel('SNR/bit')
title('Channel capacity versus SNR/bit')
ylabel('Channel capacity')


还有就是 entropy2()命令matlab中不认,那不是默认函数吗?帮帮忙 ! 急!
谢谢!
回复
分享到:

使用道具 举报

发表于 2006-10-14 11:29 | 显示全部楼层
H(p)=-sum(p.*log2(p));
Subscript indices must either be real positive integers or logicals.
H(p)这里的p应为正整数,可能问题出在这里

评分

1

查看全部评分

 楼主| 发表于 2006-10-14 12:08 | 显示全部楼层
thanks
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-25 05:28 , Processed in 0.051033 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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