Category Archives: Quora Answers

Is it true that “engineers design systems to manage pressure and flow?”

This is an answer to a question originally asked on Quora.com. You can find the original here:
Is it true that “engineers design systems to manage pressure and flow?”

An electrical engineer was explaining how electricity works in buildings to me, and I got the impression that all of engineering can be boiled down to managing pressure and flow in systems. This seems too simple to me, and I think there is more to it.  Can someone help me understand what I am missing?.

Answer by Rustin Bergren:

What you’ve stumbled upon is called the Hydraulic analogy. It’s an incredibly useful tool for teaching the very basic concepts of electricity in circuits. Interestingly, the ideas of a ‘pressure’ and a ‘flow’ can be extended to mechanics and thermal systems (and computer networks and vehicle traffic engineering and on and on).

Here’s a chart from (the wikipedia page: System equivalence) showing the relationship between parameters of different systems.

(note: I have a couple of disagreements with this chart; however, pointing them out is not really not germane to the answer)
It doesn’t work perfectly, however. Notice, there isn’t an equivalent term for inductance in thermal systems. From this, I think we can gather that Thermal systems do not oscillate (I’m pretty sure).
Also, the simple fluid analogy for electrical engineering becomes pretty much useless after a first semester circuits course. It’s great for understanding the overall qualitative constructs of the stuff at hand, but it doesn’t get you much farther than that. For that matter, this simplistic fluid analogy wouldn’t get you all that far into an understanding of fluid mechanics.

So what you really have here is a case of having a hammer causing you to see everything you come in contact with to look like a nail. Indeed, we can draw analogies between numerous types of systems, though many times we have to modify the hammer a bit to make it work for that particular type of nail.

So yes, you’re right. It’s way too simple if you’re trying to reduce all of engineering to a simple metaphor. So it’s not at all about ‘pressure’ and ‘flow’ if you want to boil engineering down to something. What it can all be boiled down to is the application of mathematics and physics. In the case of RF Engineering (electrical) and Aeronautics (mechanical), it has to do with applying a lot of Vector Calculus. In the case of Control Systems Engineering (electrical/mechanical) and Heat Transfer Engineering (mechanical) it’s more about solving Partial Differential Equations (PDEs).

But, if you’re trying to explain the basics of how power distribution in a building works to a non-engineer, making a water analog (something most people can easily picture in their heads) works extremely well.

 

“Must we learn command lines…?”

This is an answer to a question originally asked on Quora.com. You can find the original here:
Must we learn command lines (e.g. Make, Bash or -o)?

Must we learn command lines (e.g. Make, Bash or -o)?

Can’t we use a programming or scripting language to create scripts and/or macros? I’m having trouble with Bash commands and I’m lazy trying to figure out how to solve it and was wondering whether learning Bash is worth it.

Answer by Rustin Bergren:

No, you mustn’t. But keep in mind that many things are really just pretty interfaces that convert mouse clicks and field contents in to commands at a lower level that is transparent to you. If you want to understand something well and use it to its fullest potential it’s often best to understand its native language. That said, some things absolutely suck trying to speak to at this fundamental language–which is why Photoshop is way better for doing basic editing on a single image than ImageMagick (note, I say single image).

As far as make, there are plenty of more advanced build environments that totally obscure dependency and conditional compilation details away from you (hide by default really, you can do all and more with them when you dig down) and handle them in the background (somewhat). Xcode for example. But, heaven help you if everything doesn’t always coincidently work the way you expect it to. And if you’ve ever programmed anything, you know how often what you expected to happen doesn’t. Having an intimate knowledge of how things are working underneath makes debugging such things SO much easier. Otherwise when stuff doesn’t work as expected (and I see this all the time) people just takes stabs in the dark as to what the problem is, iterating different possible things, changing this option, that option, restarting, etc. When just a basic knowledge of how the underlying components work together would allow one to systematically check each part, test hypotheses, rule out others and ultimately verify that everything is working as suspected. The compilation tools in Xcode are great and by no means am I attacking them, but having an intimate understanding of what’s going on under the surface is invaluable. To that end, sometimes it’s easier to learn the basics of compilation and build with a much less sophisticated tool like Make.

If you’re interested in being a hacker or system administrator you should definitely learn bash. Especially if you are particularly lazy (like me). That’s right, learning these tools allows you to spend less time doing repetitive boring tasks–that’s the point.

There’s also other benefits to command line type systems, that you will find to like after some time using them.

  • It’s really easy to keep track of what you did to get something to where it is. Often this can be a single screen shot that not only shows the commands you typed, but the results of those commands. A great tool for this is the script command. According to the man-file

    The script utility makes a typescript of everything printed on your terminal…

  • It’s very easy to communicate how to do something in a command line to someone else. Have you ever read a tutorial on how to do something in a gui–scrolling through pictures of mouse clicks? You know what’s worse? Writing a tutorial on how to do something in a gui.
  • It’s easier to script stuff that is fundamentally command-line based. Scripting mouse movements and clicks at horribly tedious. Also, don’t get me started on icons. There’s really just no intuitive way to infer an script line like: “click on the little button that looks like an arrow trying to escape a box…or maybe its an umbrella on a square table…yeah click that and then a new box will magically appear, click the little picture in that box that looks like…”. GUIs sometimes have a scripting interface you can talk to directly (Applescript calls these Scriptable Applications), but these are NEVER any better documented than the gui software itself. And go figure, after tediously writing a manual on how to do stuff in the gui for their application, who wants to write documentation on the scriptable interface no one ever uses anyways. You ask about scripting, theres nothing easier to script than a command line application.
  • Configuration patterns and common tasks, even complicated ones can be very quickly applied. You can just cut and paste them from your “notebook”.

That said, some things absolutely suck when doing them from the command line. But, that’s the answer to a different question.

Matlab: How to use extrapolate from spline (or anything similar) curve to show whether new data fits that curve? (read detail section for…

Answer by Rustin Bergren:

I think what you’re trying to do is have MATLAB ‘give’ you the curve of the 2D spectrogram plot such that you can compare column evaluations with the proposed spline curve. Then you can say, “yes, the max value in this column is within xx of the spline; therefor, its part of the set.” Is that right?

The problem is, there are literally an infinite number of regressions that will match your data. If you supply the spline algorithm with data points that are part of a curve you’re not really interested in, then they will effect the overall curve and in many cases the new curve will now match those. So what you would need to do is remove those points you don’t want smoothed in to the calculated spline; however, it seems like what you’re trying to do is find out what those points are. In which case, we’re now chasing our own tail.

By example
Let’s take a curve like this:

1
2
3
x = 0:10;
y = 10.*x.^2+3.*x;
plot(x,y,'o');

Now let’s modify some of the points on the end so it doesn’t match the curve perfectly.

1
2
3
4
5
y_data = y;
y_data(end) = y_data(end) - 888;
y_data(end-1) = y_data(end-1) - 400;
plot(x,y_data,'o');
ylim([0,1200]);

Without adjusting anything let’s spline based on all those points

1
2
3
yspl = spline(x,y_data,0:.1:10);
plot(x,y_data,'o',[0:.1:10],yspl,'.');
ylim([0,1200]);

The red dashed line is the calculated spline. While our data points are from 0, 1, 2…10; I configured the resultant spline to interpolate 10 times that resolution so it’s defined at 0,.1,.2,.3,…10.

But hey! That’s not what we want. That spline just included the data points we were trying to ignore. So what can we do? Well, let’s exclude some of the points from the calculation.

I’m going to remove the first 3 and last 3 by using range selections but with essentially the same command. Notice, you can keep the same range parameter (the third term in the spline function call)–this will now extrapolate the calculated spline on to that range.

1
2
3
yspl = spline(x(4:end-4),y_data(4:end-4),0:.1:10);
 
plot(x,y_data,'o',[0:.1:10],yspl,'.');

So that calculates the spline using only these 4 points and it doesn’t look to bad for what we were trying to do.

The problem, however, is how do you know from your series which points to include and which to remove? It seems like your trying to do all this programmatically. Can you just assume that the max column values from 30% to 60% of your x range are valid points within your animal call? If so, then gravy–try doing this.

You can also try smoothing, which is essentially the same as the spline but it allows you to supply a smoothing parameter. Notice however that our bad values at the end, if included, still mess us up

1
2
3
yspl = csaps(x,y_data,.1,0:.1:10);
plot(x,y_data,'o',[0:.1:10],yspl,'.');
ylim([0,1200]);

Not only does smoothing not cause the interpolated curve to not move too much away from our down sloping points at the end, but it also moves the spline curve away from the data points that match our curve.

I hope this answers your question. If you want to know how to extract the points from your FFT, and use the functions I listed, please mention so in the comments. So to review quick, the spline function is called like this:
spline(x_datapoints, y_values_at_x_datapoints, new_x_range)
The new_x_range allows you to both interpolate and extrapolate the calculated regression function.

To be honest, if your trying to isolate the audio sections, while a novel idea, I don’t think this is the best way to go about this. Thanks for the A2A!

Matlab: How to use extrapolate from spline (or anything similar) curve to show whether new data fits that curve? (read detail section for…