From: Mark Yuan on
Please help me for the following question:

I have a simple function file:

function Z=F(X,a)
x=X(1);y=X(2);
Z=zeros(1,2);
Z(1)=a+x^2-2*x-y+0.5;
Z(2)=2*a+x^2+4*y^2-4;

For single value of a and give a initial, it's no prob to get the values of Z,
e.g., a=1; A=feval('F',[0.2,0.1],a)

But if a is a vector including 100 values, e.g., a=[1 2 3...], how can I
get the values of Z related to such a? the results should be a matrix with 2 by 100.

Thanks!
From: ImageAnalyst on
function test1
clc;
workspace;
a=1:100;
X = rand(1, 100);
A = F(X,a)


function Z=F(X,a)
x = X(1);
y = X(2);
Z = zeros(2, length(a));
Z(1, :) = a + x^2 - 2*x - y+0.5;
Z(2, :) = 2*a + x^2 + 4*y^2 - 4;