フィルターのクリア

index must b positive?plz help

2 ビュー (過去 30 日間)
khushi
khushi 2015 年 8 月 22 日
回答済み: Walter Roberson 2015 年 8 月 22 日
clc;clear all;
g_db=[0:1:10];
g=10.^(g_db/10);
alpha=2;
c=1;
M=2;
syms y
r=0;
for j=2:M
p=((-1)^j)*(factorial(M)/factorial(j)*factorial(M-j))*exp(-(g.*y(1-(1/j))));
r=r+p;
t=r*(1/M)
end
x=((y.^(alpha-1)).*exp(-y./c))/((gamma(alpha))*(c^alpha));
z=t*x;
semilogy(g_db,z);
hold on

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 8 月 22 日
You have the expression
p=((-1)^j)*(factorial(M)/factorial(j)*factorial(M-j))*exp(-(g.*y(1-(1/j))));
The y(1-(1/j)) part of that says to index the variable y at index (1-(1/j)) . As all of your j are at least 2, 1/j is less than 1 so 1-1/j is not a positive integer.
Perhaps you wanted to code multiplication instead of indexing. y*(1-(1/j))

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by