|
From: | Nicholas Jankowski |
Subject: | Re: vector function within vector function |
Date: | Thu, 31 Dec 2015 00:40:10 -0500 |
I think I understand the error message now. Since each variable is assumed
to be a matrix, p2 will clearly be incompatible with x. Does this mean I
have no choice but to use a for loop (like below)?
num=200;
b1=linspace(200,225,num);
b2=linspace(0.33,1.0,num);
[xx,yy]=meshgrid(b1,b2);
function val=ls(p1,p2)
val=0;
x=[1,2,3,5,7,10];
y=[109,149,149,191,213,224];
#val=sum((y-p1.*(1-exp(-p2.*x))).^2); #<== nonconformant arguments (op1 is
200x200, op2 is 1x6)
for i=1:6
val+=(y(i)-p1.*(1-exp(-p2.*x(i)))).^2;
end
endfunction
z=ls(xx,yy);
[Prev in Thread] | Current Thread | [Next in Thread] |