getting error Subscript indices must either be real positive integers or logicals.

1 vue (au cours des 30 derniers jours)
Dear all
i write a code when i run this i got error "Subscript indices must either be real positive integers or logicals." code is as follows
function z=aa(p,a,q)
t=0;
z=((p(t)-1200+150)*(-d)*(0.45+0.75*log10(abs(a(t)))+0.1*2)*(100-2)*exp(-.004*p(t))*exp(.4*q(t))...
+(0.45+0.75*log10(abs(a(t)))+0.1*2)*(100-2)*exp(-.004*p(t))*exp(.4*q(t)))^(2);
any one please tell me the solution
Thank you

Réponse acceptée

Nathaniel
Nathaniel le 19 Juin 2012
I'm assuming that you are intending p to operate as a function, but maybe you are not passing in a function handle?
Matlab appears to be interpreting it as a matrix, and so p(t) evaluates to p(0), i.e., the 0th element of p, rather than "p of 0" which is what I suspect you want. Since Matlab indices are 1-based, p(0) throws the "...real positive integers or logicals" error.
  2 commentaires
MD NASAR
MD NASAR le 19 Juin 2012
Actually i want the value of p(0),P(1) etc

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by