Solving for variables in matlab

  • Thread starter Thread starter Dell
  • Start date Start date
  • Tags Tags
    Matlab Variables
AI Thread Summary
The discussion focuses on solving for the variable Sz in MATLAB using vectors S, P, and Q under specific orthogonality conditions. The user has successfully set up the initial equations and derived a condition for orthogonality, resulting in the equation 36 + 3*Sz = 0. They seek guidance on how to instruct MATLAB to solve this equation for Sz, specifically to obtain Sz = -12. The conversation emphasizes using the 'solve' function in MATLAB to find the solution. The user is looking for a method to automate this process for different conditions.
Dell
Messages
555
Reaction score
0
i need to make a code that can sole the following, finding the value of Sz
given the following vectors

S=[ -6, -6, -Sz]
P=[ 0 -6 -3]
Q=[ 5 4 -9]

i need to make a code that can find Sz so that
a)S \botP
b)S\botQ
c)S\bot(PxQ)
d)(SxP)\botQ

i have managed to make MATLAB give me a condition for \bot, for example, what i set up is:

>>Sz=sym('Sz');
>>S=[ -6, -6, -Sz];
>>P=[ 0 -6 -3];
>>Q=[ 5 4 -9];
>>answer=S*P'


matlab returns
answer =

36+3*Sz


and i know that answer=0, therefore Sz=-12, but how do i get MATLAB to tell me that Sz=-12??
 
Physics news on Phys.org
build a string that is

'36+3*Sz = 0'

teh num2sr() command may help if the answer is not 0 all the timethen its just:
>> solve('36+3*Sz = 0')
 
Last edited:

Similar threads

Replies
0
Views
1K
Replies
1
Views
2K
Replies
3
Views
1K
Replies
1
Views
299
Replies
10
Views
3K
Replies
6
Views
2K
Replies
10
Views
2K
Back
Top