Formula for plotting a half-circle waveform.

Have you ever wondered what the formula for that thing that looks like a sine wave, but is really just half circles? Well, take a look below for the Matlab code of how to generate and plot such a signal with a particular frequency. If you need help translating to another programming or graphing language, just let me know.

Also, a handy feature of this code is the ability to only plot the first N periods. Take a look! :-)

Fs = 100;                     % Sampling frequency
T = 1/Fs;
L = 1000;                     % Number of samples
t = (0:L-1)*T;                % Time vector

fs = 1;                       % Frequency of signal.
A = 1;                        % Amplitude of signal.
% Half-circle waveform:
r = 1/(fs*4);
y = (A/r)*((2*(mod(t,r*4) == mod(t,2*r)) - 1).*sqrt(r^2 - (mod(t,2*r)-r).^2));

% Regular sine waveform:
y2 = A*sin(2*pi*fs*t);

% Plot the waveforms.
numPeriods = 3;
tEnd = round(numPeriods/(T*fs));
plot(t(1:tEnd),y(1:tEnd),t(1:tEnd),y2(1:tEnd))

 

Timestamp to Human Readable Date

This is some simple code I cooked up to convert a unix timestamp into a human readable date. The code will work up to the year 2100, when it will incorrectly add a leap day. Anyway, I couldn’t find this anywhere on the Internet, so maybe someone else will find this useful.

void dateAndTimeFromTimestamp(int i)
{
   int days    = i/(24*3600);

   // How many 4-year segments do you have (going 365, 365, 366, 365 days)
   int year    = days/(365*4 + 1);
       year    = 1970 + year*4;

   // How much is left over when you divide days into 4-year segments
       days    = days%(365*4 + 1);
   if(days >= 365 && days < 2*365)
   {
      days -= 365;
      year += 1;
   }
   else if(days >= 2*365 && days < 3*365 + 1)
   {
      days -= 2*365;
      year += 2;
   }
   else
   {
      days -= (3*365 + 1);
      year += 3;
   }

   int seconds = i%(24*3600);
   int hours   = seconds/3600;
       seconds = seconds%3600;
   int minutes = seconds/60;
       seconds = seconds%60;

   int month;
   for(month=1; month <= 12; month++)
   {
	// 30 days has September, April, June, and November
	if((month == 4 || month == 6 || month == 9 || month == 11) && days >= 30)
		days -= 30;

	// Except for February, which has 28 days
	// (the 29 days on leap year already accounted for above)
	else if(month == 2 && days >= 28)
		days -= 28;

	// All the rest have 31
	else if(days >= 31)
		days -= 31;

        else
                break;
   }
   days++;

   printf("%d-%d-%d %d:%d:%d",month,days,year,hours,minutes,seconds);
}

Wanda Lee

As many of you already know, my grandmother passed away this week. We all miss her greatly. I was privileged to spend the last couple of days remembering her life with my family as we traveled to her funeral in northwestern Missouri. My Dad wrote an excellent tribute that I thought I would share with you all, along with a slideshow of pictures.

A Tribute to Mom, by Fred McClurg

Grandma McClurg was born on October 20, 1925, near Darlington, Missouri. After graduation from high school and college in Maryville, Missouri, she taught at one-room school houses near Burlington Junction, Missouri.

On May 21, 1950, Wanda Lee Grace was united in marriage with Lloyd McClurg. In 2009, they celebrated their 59th wedding anniversary. They lived and farmed south of Pickering, Missouri, where they raised their four children.

She was also involved in 4-H Clubs and was instrumental in starting a chapter in Nodaway County. She recruited leaders for cooking, knitting, sewing, horsemanship, conservation, livestock, and rabbit clubs. She was also a lifetime member of the Bloomfield Community Club for historical preservation. She also enjoyed working in her wildflower gardens.

Wanda Lee was a charter member of Laura Street Baptist Church in Maryville where she served in many capacities including: Jr. High Sunday School Director, Vacation Bible School Teacher, and Meal Ministry Helper. Reading the Bible was an important part of her life. She loved her children, grandchildren, and great-grandchildren and she will be greatly missed by all of them.

Taglines

This blog has had four different taglines in the course of its history. By popular demand, here are the explanations.

1. “Join me for a party in my mind.”

This line was an inside joke among my family and friends during my first years of blogging. As one particular birthday celebration was drawing to a close, I said something to the effect of “You can send me home any time you like, but I’m going to keep partying in my mind.” The phrase stuck, and was used whenever I did or said something odd — i.e. “Been partying too hard in your mind, Josiah?” At the time, I enjoyed perpetrating the notion that I was hilarious, interesting, and above all unusual. Moreover, the phrase included the word “mind,” which I thought would give the impression that I used it frequently. I designed a custom festive theme for the tagline, and began my new lighthearted blog.

2. “Party’s over, folks. This mind’s a war zone.”

After some time, I stopped viewing myself as a source of entertainment for others — or myself. I was working very hard to excel academically, socially, and occupationally, and wanted to be taken seriously. The tagline was meant to reflect on the battleground of ideas in which I thought myself furiously engaged. I added a background image to illustrate the point.

More than that, this was a time of intense mental turmoil for me as I sorted out my relationship with God (incidentally, the background image was created using a photo of Charles Templeton), my family members, and other people. There were many conflicting options about what I should pursue in life, and which things would have to “fall through the cracks.” I was eventually able to reach some conclusions and make some decisions that I could live with. However, the effort left me extremely drained, mentally, emotionally, and even physically — which leads nicely into the next tagline.

3. “The web’s first time graveyard.”

Not feeling as if I had anything left to say, and feeling too tired to really do much serious thinking, the blog took a hiatus of sorts. The theme was a blank white background with grey text. The tagline was taken from the middle of an unfinished and almost laughably brooding poem.

Not a soul to be found in this graveyard mind,

Nought is buried here but time.

4. “Stay if you like, but don’t expect too much — yet.”

The most recent tagline reflects my quantity-based approach to getting the blog going again. My Rhetoric teacher Pat Dolan wisely told us that the only way to improve our writing was to do more writing. I’m going to take that approach. It will likely take a while for my mental and creative juices to start flowing again after stagnating for some time, so don’t expect anything too interesting right away — but also don’t rule that possibility out! I’m hoping this blog is on the upswing! :-)