Subscript indices must either be real positive integers or logicals. why does this come up?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Walter Roberson
el 29 de Jun. de 2016
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 comentarios
Darcy Love
el 29 de Jun. de 2016
Editada: Walter Roberson
el 29 de Jun. de 2016
Walter Roberson
el 29 de Jun. de 2016
1/1 is 1, so 1/1-sigma is the same as 1 - sigma. I suspect you want x^(1/(1-sigma))
Ver también
Categorías
Más información sobre Discontinuities en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!