[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Function of vector with meshgrid and surf

**From**: |
Sebastian Schöps |

**Subject**: |
Re: Function of vector with meshgrid and surf |

**Date**: |
Wed, 11 Nov 2015 23:02:52 -0800 (PST) |

karl wrote
>* function fr = frame1 (x)*
>* fr=x(1)+x(2);*
>* endfunction*
>* *
>* Is it possible in this case, i.e. with no modification of frame1, to avoid*
>* looping?*
No. You will always need two iterations to evaluate all combinations of x
and y. However, these loops can be vecorized if your function allows it. In
your case it seems that only one of the two loops can be vectorized.
Please consider that the input of your function is a 11-by-22-MATRIX if you
try to vectorize both loops. Thus the following does not make sense (it
assumes that x is a 2-by-1 vector):
function fr = frame1 (x)
fr=x(1)+x(2);
endfunction
if you do not believe me, ask Octave:
function fr = frame1 (x)
size(x)
fr=x(1)+x(2);
endfunction
--
View this message in context:
http://octave.1599824.n4.nabble.com/Function-of-vector-with-meshgrid-and-surf-tp4673436p4673448.html
Sent from the Octave - General mailing list archive at Nabble.com.