MATLAB: How to make output single column in the same line as your calculation

:coloncolumnoutputreshapesinglevector

Hi there. Whether my google and matlab searching is just crap or it hasn't been asked i can't find the answer to the above question. I've found that you can make something into one column using A(:) or 'reshape', but i wan't to make a single column vector in the same line as the calculation to avoid having a second variable for each i create. e.g. if i could write A=(sqrt(B^2+C^2))(:), that would be great but matlab doesn't accept that. at the moment i am having outputs with 81 columns which is causing Nans in my code with the error saying
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN
hat i have done is put in a column vector of 81 numbers, applied the cosine rule rearranged for the angle and it outputs with 81 columns. So a second question, which i have just thought of when writing this, which may precede the first is, 'why is matlab outputting 81 full columns for what should only be a 1*81 column vector?' My code is below,
clear
clc
Spec_Sheet_CR500
theta_input=degtorad((-10:0.25:10))
theta=theta_input(:)
sh_hyp=sqrt(sh^2+so^2)
sh_a=atan(so/sh)
sh_b=atan(sh/so)
lmh_hyp=sqrt(lmh^2+lmv^2)
lm_to_sm=sqrt((lh+sh)^2+(lo-so)^2)
beta_1=sqrt(sh_hyp^2+lmh^2-2*sh_hyp*lmh*cos(sh_b+theta))
beta_1_A=(acos((sh_hyp^2+beta_1.^2-lmh^2)/(2*sh_hyp*beta_1)))
beta_1_B=acos((lmh^2+beta_1.^2-sh_hyp^2)/(2*lmh*beta_1))
beta_2=sqrt(beta_1.^2+lmv^2-2.*beta_1.*lmv.*cos(beta_1_B+(pi/2)))
beta_2_A=acos((beta_1.^2+beta_2^2-lmv^2)/(2*beta_1.*beta_2))
beta_2_B=acos((beta_2^2+lmh_hyp^2-sh_hyp^2)/(2*beta_2*lmh_hyp))
gamma_1=sqrt(lm_to_sm^2+beta_2^2-2*lm_to_sm*beta_2*cos(beta_1_A-beta_2_A-sh_a-psi))
alpha_1_A=acos((link3^2+gamma_1^2-link_arm^2)/(2*link3*gamma_1))
alpha_2_A=acos((lmh_hyp^2+gamma_1^2-lh_hyp^2)/(2*lmh_hyp*gamma_1))
ksi=alpha_2_A+(alpha_1_A-link2_A)
H=sqrt(link1^2+lmh_hyp^2-2*link1*lmh_hyp*cos(ksi))
l=sqrt(beta_2^2+link1^2-2*beta_2*link1*cos(beta_2_B+ksi))
sigma=(acos((sh_hyp^2+l^2-H^2)/(2*sh_hyp*l)))-sh_a
many thanks

Best Answer

reshape(X,[],1)
for any array/matrix/vector X