"some how it stops after 3 itrations at z = 0.03"
That's actually not true. In your script, z contains 4 values and the loop has 4 iterations
1 0.99998 0.9999 0.99978 0 0 0
You're initializeing A as a 1x31 vector of zeros which is why there are extra value in the output.
There's nothing wrong with your loop but I find it more intuitive to loop over intergers 1:n rather than looping over elements of a vector directly. Consider this version,
A(i) = 1/(1+((z(i)/aes)^2));
Result:
If you intended to have 31 iterations, define z in the first line of my version as
and then run the rest of my version.
Result:
1 1 1 1 1 0.99999 0.99999 0.99999 0.99998 0.99998 0.99998
0.99997 0.99996 0.99996 0.99995 0.99994 0.99994 0.99993 0.99992 0.99991 0.9999 0.99989
0.99988 0.99987 0.99986 0.99984 0.99983 0.99982 0.9998 0.99979 0.99978
Best Answer