matlab - Print results on command window -
i have stupid problem simple script written on matlab:
z=(rasis-lasis)/norm(rasis-lasis); v=(rasis-psis)/norm(rasis-psis); y=cross(z,v)/norm(cross(z,v)); x=cross(y,z); r_pel=[x',y',z']; o_thigh=(le+me)/2; y=(hf-o_thigh)/norm(hf-o_thigh); u=(le-o_thigh)/norm(le-o_thigh); x=cross(y,u)/norm(cross(y,u)); z=cross(y,x); r_thigh=[x',y',z']; r_j=r_pel'*r_thigh; ang_beta=asin(r_j(3,2))*(180/pi); ang_alpha=-asin(r_j(1,2)/cos(ang_beta))*(180/pi); ang_gamma=-asin(r_j(3,1)/cos(ang_beta))*(180/pi); the problem that, on command window insert rasis, lasis, psis, le, me, hf vectors , click enter , variables appear on workspace column on right relative value assigned them; now, run script make calculate variables z, v, y etc. , variables want calculate appear on workspace. how can make them appear on command window too, example, in form (if result matrix):
ans= x x x x x x x x x ?
if leave off ; @ end of line, matlab display result of line on command line:
z=(rasis-lasis)/norm(rasis-lasis) v=(rasis-psis)/norm(rasis-psis) a better way use disp function:
disp(z); disp(v); %// etc... and better way produce formatted output using [sprintf]:(http://www.mathworks.com/help/matlab/ref/sprintf.html)
sprintf('z:%10f\r\nv:%10f',z,v) where \r\n new line , %10f insert float taking 10 characters , padding spaces @ front (which helps left align numbers. can specify how many decimal points want changing %10f %10.3f example.
Comments
Post a Comment