solve non-linear equations

1 次查看(过去 30 天)
AR
AR 2016-4-9
Anyone have any ideas of how to solve non-linear equation in matrix form? I want to generate 100-paired, x1, x2, Y samples from model:
Y=sigmoid*(a1'X)+(a2'X)^2+0.30*(X')?
where
X=[x1,x2] is N x p matrix with x1, x2 normally distributed vectors
sigmoid=X/sqrt(1+X^2)
a1=(3,3) are coefficients for x1 and x2
a2=(3,-3) are coefficients for x1 and x2
*****************************
My unsuccess MatLab code:
N=100; % number of samples
a1=[3 3];
a2=[3 -3];
a1rep=repmat(a1,N,1); % N x p matrix of a1 constants for x1 and x2
a2rep=repmat(a2,N,1); % N x p matrix of a2 constants for x1 and x2
syms x1 x2 y
for n = 1:N % number of samples to solve for y, x1, x2
S = vpasolve([[x1,x2]/sqrt([x1,x2]^2)*(a1rep'*[x1,x2]) + (a2rep'*[x1,x2])^2 + 0.30*[x1,x2]' == y], [x1, x2, y])
[x1n(n),x2n(n)]=S; %create matrix of x1 and x2 values renamed as x1n, x2n for each of sample solution of y
end
yValues=[x1n,x2n]/sqrt([x1n,x2n]^2)*(a1rep'*[x1n,x2n]) + (a2rep'*[x1n,x2n])^2 + 0.30*[x1n,x2n]'; %vector of y values for each x1,x2 pair
  1 个评论
John D'Errico
John D'Errico 2016-4-9
What are you talking about? If X1 and X2 are normally distributed, then generate them as such, and then evaluate the sigmoid function to compute Y.
I have absolutely no idea what you mean by this:
a1=(3,3) are coefficients for x1 and x2
as that is not valid MATLAB syntax.
I have also no idea what you are trying to solve. What are the unknowns? What is known? I can't even decipher what your equation is, as it is only partially written, again, with invalid syntax, even in terms of mathematics what you wrote does not make sense.
So SLOW DOWN. Start over. Explain what you are trying to do. CLEARLY.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by