Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
linear equations with vectors

Subject: linear equations with vectors

From: S?bastien Vilaseca

Date: 30 Jan, 2009 16:55:03

Message: 1 of 2

Hello, I have to solve the following system:

gamma-neutral condition:
gamma1(:,1)= nc2(:,1)*gamma2(:,1)+nc3(:,1)*gamma3(:,1)

vega-neutral condition:
vega1(:,1)=nc2(:,1)*vega2(:,1)+nc3(:,1)*vega3(:,1)

So all of the coefficients and variables are vectors. I need to find nc2(:,1) and nc3(:,1), that means the number of call c2 and c3 to have a gamma-vega neutral position. I tried with a loop but it still wasn't working... Does anybody can help me?

Thanks a lot!

Subject: linear equations with vectors

From: Roger Stafford

Date: 30 Jan, 2009 20:38:02

Message: 2 of 2

"S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <glvbd7$528$1@fred.mathworks.com>...
> Hello, I have to solve the following system:
>
> gamma-neutral condition:
> gamma1(:,1)= nc2(:,1)*gamma2(:,1)+nc3(:,1)*gamma3(:,1)
>
> vega-neutral condition:
> vega1(:,1)=nc2(:,1)*vega2(:,1)+nc3(:,1)*vega3(:,1)
>
> So all of the coefficients and variables are vectors. I need to find nc2(:,1) and nc3(:,1), that means the number of call c2 and c3 to have a gamma-vega neutral position. I tried with a loop but it still wasn't working... Does anybody can help me?
>
> Thanks a lot!

  I don't know why a proper for-loop wouldn't work, but you can also vectorize it if you solve the two unknowns - two linear equations problem explicitly:

 d = g2(:,1).*v3(:,1)-v2(:,1).*g3(:,1);
 n2(:,1) = (v3(:,1).*g1(:,1)-g3(:,1).*v1(:,1))./d;
 n3(:,1) = (g2(:,1).*v1(:,1)-v2(:,1).*g1(:,1))./d;

where g1 stands for gamma1, v1 for vega1, n1 for nc1, etc. (I was too lazy to write them all out.)

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us