Publishing to WordPress
This blog post began its life as a Live Script in MATLAB. I could have started typing into WordPress, but then I wouldn't have been able to do this.
Stand back...
m = linspace(-3*pi,3*pi,400);
[x,y] = meshgrid(m);
s = sin(x).*sin(y).*log(abs(x)).*log(abs(y));
imagesc(s)
colormap(colorcube)
axis equal off
Yowza!
That's a lot of popcorn for not very much code. What on earth is going on here? Much of the drama comes from the wildly varying colormap. Let's look at this surface from the side.
surf(x,y,s)
shading flat
colorbar
Let's strip away the color to get a better picture. What is the underlying shape?
surf(x,y,s)
colormap([0.5 0.75 0.4])
axis off; shading flat; material dull
set(gca, DataAspectRatio=[1 1 1.5])
light(Position=[10 1 10])
view([-20 30])
We can decompose it still further to see that there's a sort of egg carton texture being multiplied by a four-petal folded shape. We are conveniently glossing over some infinities along the axes.
s1 = sin(x).*sin(y);
s2 = log(abs(x)).*log(abs(y));
cla
surface(x,y,s1)
surface(x,y,s2/5+7)
axis off; shading flat; material dull
set(gca, DataAspectRatio=[1 1 0.75])
light(Position=[10 1 10])
view([-20 20])
It's fun dissecting this image in a Live Script. But that's not what I'm here to talk about today. What I want to talk about is this: I'm typing this in the MATLAB Editor and you're reading it in WordPress. How did that happen?
From code to prose
I'm sure you can imagine various tedious ways to move a Live Script onto a blogging platform. It would involve lots of copying and pasting bits of text and screenshotting individual images. But what if I told you it was super easy and only took a few seconds?
Okay, let me less hypothetical: I AM telling you it was super easy and only took a few seconds. And you can do it too, with the help of the new, free WordPress Publishing Tool available right now on the File Exchange and GitHub. And since I like MATLAB scripts and blogging, this makes me very happy. The tool was created by MathWorks developer Cheng Chen, and I've been using early versions of it for a while. One example is the post in which I announced the Mini Hack contest. Given all the MATLAB calculations in there, it would have been difficult to create any other way. But this way it's a breeze.
The easiest way to get started with the Publishing Tool is to go to the Add-Ons Explorer in MATLAB. Search for "WordPress" and add the file. Once you've got everything installed (there's a plugin on the WordPress side and an app on the MATLAB side), run the MATLAB app. After you've provided some details about your blog, just press the big "Publish" button and you're on your way.
I would provide a link to the resulting article, but you're reading it right now!
Special Thanks to Sumihiro
Today's starting image, by the way, was adapted from Sumihiro's Symmetry entry in the Mini-Hack contest that we ran last fall. That entry was inspirational, getting remixed for a record total of 32 times! Not to mention the fact that I am further remixing it right here. Thanks Sumihiro!
And if you create your own blog post using this tool, please include a link to it in the comments below!
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.