For x1, I am using a different formula f = @(t) K / (1 + (K / x0 - 1) * exp(-1*r*t)). If you try to input index like f(1), f(2), it outputs a number perfectly well and it should not be 0. I think there is a problem of how this formula is defined.
‘I think there is a problem of how this formula is defined.’
I agree. However since your coding for it is all that I have to work with, this is the best that I can do with it. Check to be certain that ‘r’ and ‘K’ have the correct values.
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.