Yes, interp2 will return an array if input queries are arrays. I was thinking about inputing scalar values as query points. Which means that data should be loaded one-by-one or be sorted out in some way.
Query points are functions of x1 and x2 as follows:
Te = f(x2)
ne = f(x1,x2)
Surface plot of inital data (surface map from which the code extracts y) is ploted in 2D and 3D (attachments).
Just for the record, to make it more clear. The aim of the code is to find optimal values of x(1) and x(2) such that y is minimized. Data for y is imported as a surface map y = f(ne,Te) where ne = f(x(1), x(2)) and Te = f(x(2)). Physical explanation is fuel consumption of a vehicle where x(1) and x(2) are variables in powertrain (gear ratio and motor speed). The problem is that I need to load drive cycle (speed and acceleration arrays) in order to calculate Te and ne. How can I import speed and acceleration data one element at a time efficiently so that ga doesnt jam with array output is the question here.