[MATLAB] Dot Operation – No More For Loop!

MATLAB is a matrix based software that is widely used in engineering. Since the software is matrix based, it is actually a lot faster to do matrix operations rather than looping.

The following is an example of how to create a filter to eliminate all non-positive numbers from an array using the dot operation instead of a for loop.

function y = negative_filter( x )
% function y = negative_filter( x )
% plugging in a matrix will return only the positive numbers in a vector

%Create a zero matrix same size as the incoming matrix for comparison
z = zeros( size(x));

%Create a "filter" matrix that return 1 if the condition is true
%It will return 0 if the condition is false
filter = (x > z);

%This function multply the "filter matrix" with the incoming matrix
%elements by elements, note the '.' in front of '*'. This line will set all
%number less than 0, or false to the earlier stated condition to 0.
y = filter .* x;

%This remove all zero terms from the matrix
y(y==0) = [];






[Aerospace] The Standard Atmosphere

When doing calculations in engineering, many of the variables that we deal with are not constants. For example, if we were to calibrate a digital altimeter to collect accurate altitude position, we need the atmospheric pressure at sea level. It would be nice if pressure stay the same, then we could just hard code that number in. Unfortunately, that is not the case. Pressure changes constantly due to a number of factors.

Because of the continuously changing nature of some of the variable we deal with, this present us with a challenge in engineering. How are we supposed to design the aircraft if conditions are keep on changing?

Well, that’s when the Standard Atmosphere come into play. In simplest terms, the Standard Atmosphere is pretty much just a model that engineers and scientists came up with that generally describe what the average conditions are like.  Continue reading