[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vector function within vector function
From: |
ken1866 |
Subject: |
Re: vector function within vector function |
Date: |
Wed, 30 Dec 2015 15:09:47 -0800 (PST) |
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);
--
View this message in context:
http://octave.1599824.n4.nabble.com/vector-function-within-vector-function-tp4674229p4674255.html
Sent from the Octave - General mailing list archive at Nabble.com.