title: Is it possible to compute all the values at the same time when writing a script?
body: <p>When defining a function, say <code>TEST = @(t) t.^2</code>. If the input is a vector, say <code>[1,2,3,4]</code>, <code>TEST([1,2,3,4]) = [1,4,9,16]</code>.</p>
  
  <p>Can we do similar thing if the function defined is in script form? What I mean is that if I have a script, say TEST.m such that <code>ret = TEST(x,y,z)</code> which outputs a value when knowing numerical values of <code>x</code>, <code>y</code> and <code>z</code>. Suppose I want to calculate 100 different values of <code>z</code> ranging from 1 to 100 when <code>x</code>, <code>y</code> are fixed, say at 0, 1 respectively. Is it possible to output <code>TEST(0,1,1:1:100)</code> without writing a for loop or changing any contents of the script TEST.m?</p>
  
  <p>The reason to ask such question comes from the computation time. Usually, the script I have may be a little complicated so that the calculate of a single value may take few minutes to go. Writing for-loop to output it can be very time-consuming. I think of writing <code>parfor</code> loop, but the computation time is still long to me for further uses. I wonder if I can calculate all the 100 values at a time. I am a starter of programmer, and I hope I can get satisfactory answers after this post. Thanks for all your help.</p>