Categories
Harmonics

Harmonic analysis - historical background

I would like to mention at the begging that for more than last three years I have been working on various aspects of harmonic in power system and power electronics. Almost all of my research activities were focused mainly on the application of harmonic analysis in large offshore wind farms. Since I started there have been few observations and ideas that I would like to share with you. From my perspective such knowledge sharing approach can bring closer harmonic analysis in electrical engineering and allow to establish a dialog between engineers and physicians from different fields of science. Let me start from the historical background of harmonic analysis.

First well documented appearance of harmonics in relation to mathematics and science is from ancient Greek. The science which pursued the investigation of multiple and epimoric (ratios of the form [n+1]:n) ratios in music was concerned with the mathematical 'fitting-together' (harmonia) of the constituent notes and intervals of music [1].

Harmonics were described by Claudius Ptolemy, who related musical harmonies to the properties of mathematical proportions derived from the production of sounds themselves. Ptolemy argued for basing musical intervals on mathematical ratios, in agreement with the followers of Pythagoras, backed up by empirical observation. Ptolemy wrote about how musical notes could be translated into mathematical equations and vice versa [2]. Those harmonies he considered to be distributed in all aspects of the physical universe. In particular, they were there in the phenomena of the planets and the human soul [3].

Nowadays, harmonic analysis is the branch of mathematics that studies the representation of functions or signals as the superposition of basic waves. It investigates and generalizes the notions of Fourier series and Fourier transforms, mathematical tools significantly useful in different areas of engineering. The basic waves are called harmonics, but the name harmonic in this context is generalized beyond its original meaning of integer frequency multiples.

It can be said that the beginning of nowadays harmonic analysis reaches back a French mathematician and physicist, Joseph Fourier, who originally defined the Fourier series for real-valued functions of real arguments, and using the sine and cosine functions as the basis set for the decomposition. Fourier series could be used only for analysis of periodic functions.

Many different approaches of defining and understanding the concept of Fourier series have been developed since that time. All are consistent with one another, but each of which emphasizes different aspects of the topic simultaneously extending significantly the basic concept of harmonic analysis. Some of the more powerful and elegant approaches based on mathematical ideas and tools not available at the Fourier time extended his original work and are successfully applied in harmonic analysis at present.

Wavelet transform of EMI
Wavelet transform of electromagnetic interference.

Many other Fourier-related transforms (e.g. Laplace transform, Fourier transform, short-time Fourier transform, wavelet transform) have since been defined, extending the initial idea to other applications. This general area of inquiry is now by physicists and engineers called harmonic analysis.

I hope this short introduction appears to be interesting for you and can encourage you to check later posts regarding various aspects of harmonic studies in engineering and large offshore wind farms. If you have any questions or comments do not hesitate to drop me a line below.

[1] D. Creese, Monochord in Ancient Greek Harmonic Science. Cambridge University Press, 2010.
[2] J. Solomon, Ptolemy Harmonics: Translation and Commentary. Brill Academic Publishers, 1999.
[3] A. Barker, Scientific Method in Ptolemy's Harmonics. Cambridge University Press, 2001.

Categories
Software

Change font name in Bode plot

I had been struggling with this problem a while before I did manage to find a work around. It was actually quite important for me to change the font name in Bode plots because I decided to use everywhere Cambria in my report. Normally Heveltiva is used by default in Matlab.

In general it is possible to change font in Matlab plots without any problems. But this is in case the standard package. It should be emphasized that each of Matlab toolboxes is developed by separated teams of specialists. That is why sometimes different features can be solved with a different approach and actually in Control System Toolbox it is not predicted to change font name. You can change the size or style but not the name.

Available parameters for different labels in case of Bode, Nyquist, etc. plots are the following

>> PlotHandle= bodeplot(TrunsferFunction);
>> PlotOptions= getoptions(PlotHandler);
>> PlotOptions.Title,
ans =

String: 'Dummy Title'
FontSize: 10
FontWeight: 'normal'
FontAngle: 'normal'
Color: [0 0 0]
Interpreter: 'tex'

As everyone can see there is not option defining the font name. Fortunately there is some space to deal with it due to the fact that it is possible to define the interpreter. In Tex it is actually possible to define font name locally in text. This can be done in the following way

PlotOptions.Title.String= '';
PlotOptions.XLabel.String= '\fontname{Cambria}{\itf}';
PlotOptions.XLabel.FontSize= 10;
PlotOptions.YLabel.String= {'\fontname{Cambria}|{\itG_{ol}}|',...
    '\fontname{Cambria}\angle{\itG_{ol}}'};
PlotOptions.YLabel.FontSize= 10;
PlotHandle.setoptions(PlotOptions),

And here is the final result.

Bode Plot Font NameAnother solution is to get the frequency response into arrays and display results using functions form Matlab base package. In this case it is also possible to change axes font name.

You can also change the default system font for all figures and axes by putting the following code at the beginning of your m-file. Please note that this will change your default font during your Matlab session. I do this quite often if I do not want to think so much preparing figures for printing.

fontname= 'Cambria';
set(0,'defaultaxesfontname',fontname);
set(0,'defaulttextfontname',fontname);
fontsize= 10;
set(0,'defaultaxesfontsize',fontsize);
set(0,'defaulttextfontsize',fontsize);

Hope this helps and looking forward to see some comments.

Categories
Software

Shapes in deep shadows and high lights in Matlab

Normally I work in different toolboxes of Matlab on purpose. Either it is for my research project purposes  or due to my research project purposes. That is why I came up with an idea to do something in Matlab that would not have any application. I wanted to do something what would look nice and be by itself. Later of course I found some interesting application areas of my work but let us start from the beginning.

Łukasz Kocewiak
Photograph by Magdalena Sozańska

I decided to use Image Processing Toolbox because, in my opinion, no matter of what working on images should always give interesting results. Why not to use some of my pictures from the past taken with my old Minolta Dynax 700si. I still should have it somewhere in the basement.

%% Gausian convolution matrix
G= [1  4  7  4 1;
    4 16 26 16 4;
    7 26 41 26 7;
    4 16 26 16 4;
    1  4  7  4 1];
G= G/sum(sum(G));

%% Picture analysis
ExampleUint= imread('Example.jpg');
ExampleDouble= double(ExampleUint);
[m n]= size(ExampleDouble(:,:,1));

%%  Linear Gaussian filter
ExampleFilterUint= imfilter(ExampleUint,G,'conv');
for k=1:10,
    ExampleFilterUint= imfilter(ExampleFilterUint,G,'conv');
    k= k+1; %#ok<FXSET>
end
ExampleFilterDouble= double(ExampleFilterUint);

Due to the fact that the picture was taken still in analog technology and scanned in any photo lat the quality is not so good. Even in the small picture (a) noise can be clearly seen. I decided to get rig of it by application of a digital filter. A lot of noise and sharp edges that can affect the final result. In order to make the picture more smooth we will use a low-pass filter (b). I decided to use Gaussian filter with the convolution matrix as presented above.

Łukasz Kocewiak 3DThis apprioach can be succesfully used if we would like to evaluate how objects are shaped by light. A good example is in case of body shaping by either attending gym or fitness. If we simply cannot assess if our muscles are sufficiently shaped, just take a picture and do some processing in Matlab. Probably other applications can be found. Please let me know if you have any suggestions by posting a comment.

And an exemplary code from Matlab showing how to display two-dimensional matrix of double precision numbers.

scrsz= get(0,'ScreenSize');
%% Show results
fi1= figure('Name','3D Plot',...
     'Position',[0.1*scrsz(3) 0.1*scrsz(4) 0.35*scrsz(3) 0.5*scrsz(4)]);
ax1= axes('Parent',fi1,'FontName','Verdana','FontSize',10);
grid(ax1,'on'),hold(ax1,'all'),
mesh(ExampleFilterDouble(:,:,1)),colormap('hot'),
view(ax1,[-150 70]),xlim([0 n]),ylim([0 m]),
Categories
Software

How to open SVG 1.1 in Visio 2007

A while ago I had a horrible problem with MS Visio 2007. I was really happy that I did manage to prepare nice vector graphics in Adobe Illustrator CS4. Among others it was a map indicating one of onshore wind farms that I analyze within the confines of my research project. Normally at work I do not have such fancy tools as Adobe software, so I had to save results in something that MS Visio would be able to open.

Clipping Path 1
Vector graphics created in Adobe Illustrator CS4.


I decided to use an open standard vector format such as SVG is. Since it is an open standard it should be possible to easily save it in Illustrator and hypothetically without any problems open in Visio. I would like to emphasize that this version (i.e. SVG 1.1)  was developed in 2003 as it is stated on the W3C website. Actually Visio can deal with SVG 1.1 but in a selective manner. How big was my disappointment when I realized that actually well described in the standard clipping path is not supported.

The same drawing with visible clipping path.

The description of the clipping path (commonly known in popular vector graphics applications) can be found on the W3C (Clipping Path) website. An exemplary code showing an application of the clipping path from an SVG file generated by Adobe Illustrator looks in the following way

<defs>
     <path id="SVGID_1_" d="M111.478,271.964c0,0-5.669,0-5.669,5.478z"/>
</defs>
<clipPath id="SVGID_2_">
     <use xlink:href="#SVGID_1_"  overflow="visible"/>
</clipPath>

If one would like to open such kind of SVG file with clipping path in Visio the error dialog box appears which is presented below. MS Visio 2007 is simply not capable to open files  including clipping path definitions. I tried to find any solution how to deal with this problem via Internet but unsuccessfully.

In the error log file generated by the software it is clearly stated which elements from SVG structure are incompatible. One of possibilities to work around this problem is to delete unsupported fragments of the code. Of course this would affect that elements of our vector graphics which should be hidden by the clipping path will be visible.

[Warning] DataType: Element <clipPath>
Context: Line 13 ID SVGID_2_
Description: Invalid children of clip-path element. Children removed

Please remember also to remove information about the clipping path from each of elements included in the vector graphics. Later in MS Visio 2007 it is possible to use other methods of masking unwanted elements or parts of them.

I hope this help and please shear your experience with me regarding this problem by adding a comment. Cheers!