Recently, I had to deal with a set of data, some from experiments, and some obtained using MATLAB “Curve Fitting Tool”. As much as I like MATLAB figures, I usually find Excel features more desirable for good-looking plots! So, I needed to extract the data of Curve Fitting Tool. Here is what I did:

Save the figure as a “.fig” file.

Make a m-file with the following code to get the x, y data of the curve!

% Reads the figure file

% Gets the object of type line from the figure

% Obtains the "x" and "y" data of the curves

Then you have access to the data, and you can get the arrays as

% Assuming there are only 2 curves in the figure
% Gets the data as arrays

% x-values of 2 curves
x_data_curve_fit = x_data {1,1};
x_data_experimental = x_data{1,2};

% y-values of 2 curves
y_data_curve_fit = y_data {1,1};
y_data_experimental = y_data{1,2};

Then, your data is ready to copy/export to Excel.

Wordpress/Python integration

Why does it matter? Because we might need to write several posts with relatively similar content at the same time.

First of all, I need to install a Python library to interact with the WordPress blog. We can install it easily by the following code in command prompt. Open CMD.exe in your windows machine, and run:

pip install python-wordpress-xmlrp

This command will add python-wordpress-xmlrpc library to your installed Python. This library interacts using WordPress XML-RPC API. It is very easy to work with this library. I need to first import the required classes as:

from wordpress_xmlrpc import Client
from wordpress_xmlrpc.methods import posts
from wordpress_xmlrpc import WordPressPost

Then I need to declare my WordPress blog login information:

your_blog = Client('', 'USERNAME', 'PASSWORD')

Then, I can access to the posts by the following line:

Now, I want to write a new post and publish it in my WordPress blog:

post = WordPressPost()
post.title = 'MY_POST_TITLE'
post.content = 'YOUR_POST_CONTENT' =
post.post_status = 'publish', post))

In line 2, I can choose the title of the post. In line 3, I can choose the URL of the post. For example, I can choose “how-to-use-python-to-write-a-post-in-your-wordpress-website“. In line 4, I can write my post content. New lines, new tabs, and etc. can be used according to Python syntax. In line 6, you set the status of the post as “publish”ed!

and, the post is automatically uploaded in the WordPress blog.

More information on this Python library : python-wordpress-xmlrpc