Subscript indices must either be real positive integers or logicals. why does this come up?
12 次查看(过去 30 天)
显示 更早的评论
Trial>> AusProfInt(2, 1, 1.5, 3, 100, 0.7)
Subscript indices must either be real positive integers or logicals.
Error in AusProfInt (line 8)
Ausdemand1= -(A*2^2)/2 + (A*((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*(1 +
((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa*(-1 + sigma))*2^3)/ (pa*(-3 + sigma)*(2 -
3*sigma + sigma^2)* (((1 + ((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa)*sigma*2)/(-1 +
sigma))^sigma) + (A*(pa + 2)^2*(pa*(-2 + sigma) + 2))/ (pa^2*(-3 + sigma)*(2 - 3*sigma
+ sigma^2)* ((sigma*(pa + 2))/(-1 + sigma))^sigma)+ (A*1^2)/2 +
(A*((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*(1 +
((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa*(-1 + sigma))*1^3)/ (pa*(-3 + sigma)*(2 -
3*sigma + sigma^2)* (((1 + ((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa)*sigma*1)/(-1 +
sigma))^sigma)+(A*(pa + 1)^2*(pa*(-2 + sigma) + 1))/ (pa^2*(-3 + sigma)*(2 - 3*sigma +
sigma^2)* ((sigma*(pa + 1))/(-1 + sigma))^sigma);
0 个评论
回答(2 个)
Walter Roberson
2016-6-29
In that code, you could get that error if pc is a variable instead of a function and x is not a positive integer. Did you want pc*x instead of pc(x) ?
I note in your code that in several places you have
x^1/1-sigma
or
p(x)^1/1-sigma
I think it is unlikely that you want that code to be like that. x^1 is the same as x, and dividing by 1 would give you the same value you had, so x^1/1-sigma would be the same as x - sigma but I suspect you want x^(1/(1-sigma)) . I recommend, by the way, that you store that (1/(1-sigma)) into a variable in an earlier line and use the variable name instead of repeating the expression.
5 个评论
Walter Roberson
2016-6-29
1/1 is 1, so 1/1-sigma is the same as 1 - sigma. I suspect you want x^(1/(1-sigma))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discontinuities 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!