- #1
Adam Holland
- 7
- 0
So like the title says, I'm new to Matlab. I took a programming class on Fortran last year before my college changed the requirement so programming is not new to me all together. For a few of my classes we are allowed to use programs such as Matlab and Maple to help us solve problems. Most of them being physics classes (specifically statics) we deal a lot with vectors and use the notation xi+yj+zk. I was wondering if there was a way to solve systems of equations in Matlab such as the sum of the forces in x,y,z and the sum of the moments in x,y,z and being able to keep this notation of the unit vector multipliers. I tried just entering my vectors as 1:3 matrix and having each spot multiplied by the respective operator.
ex:
syms i j k
A=[2*i 3*j 1*k]
B=[1*i 2*j 3*k]
However I quickly found out that when taking cross products this can quickly get confusing when the program returns combinations of the operators which i would have to make sure and keep careful track of when getting my final answer and double checking.
ex:
cross(A,B)
ans=
[ 7*j*k, -5*i*k, i*j]
So is there a way to keep them separate as to and retain "i,j,k" and/or possibly have an if statement of something of the sort so that when you get say i*j Matlab will catch it and automatically replace it with k?
Thanks for the help. Sorry if I have trouble with any replies, like i said I don't know Matlab, just Fortran so please bear with me as I try to halfway teach myself this language.
ex:
syms i j k
A=[2*i 3*j 1*k]
B=[1*i 2*j 3*k]
However I quickly found out that when taking cross products this can quickly get confusing when the program returns combinations of the operators which i would have to make sure and keep careful track of when getting my final answer and double checking.
ex:
cross(A,B)
ans=
[ 7*j*k, -5*i*k, i*j]
So is there a way to keep them separate as to and retain "i,j,k" and/or possibly have an if statement of something of the sort so that when you get say i*j Matlab will catch it and automatically replace it with k?
Thanks for the help. Sorry if I have trouble with any replies, like i said I don't know Matlab, just Fortran so please bear with me as I try to halfway teach myself this language.