I noticed that for me there was unpredictable behavior when evaluating vectors. It seems like it really is as if it were straightforward than indexing in a loop. Can anyone help me? I know it probably explains how it performs each operation, so I need some clues on how to look for it.
thanks for the consultation in advance thanks
Example:
x=[0.05:.01:3]; n=size(x,2); y1 = (8*x-1)/(x)-(exp(x)); for i=1:n y2(i)=(8*x(i)-1)/(x(i))-(exp(x(i))); end a1=[x;y1]; a2=[x;y2]; plot(x,y1, 'red') hold on plot(x,y2, 'blue')
here's the plot: http://i.stack.imgur.com/qAHD6.jpg
results:
a2: 0.05 -13.0513 0.06 -9.7285 0.07 -7.3582 0.08 -5.5833 0.09 -4.2053 0.10 -3.1052 0.11 -2.2072 0.12 -1.4608 0.13 -0.8311 0.14 -0.2931 0.15 0.1715 0.16 0.5765 a1: 0.05 6.4497 0.06 6.4391 0.07 6.4284 0.08 6.4177 0.09 6.4068 0.10 6.3958 0.11 6.3847 0.12 6.3734 0.13 6.3621 0.14 6.3507 0.15 6.3391 0.16 6.3274
source share