{"id":225,"date":"2012-10-04T13:05:44","date_gmt":"2012-10-04T12:05:44","guid":{"rendered":"http:\/\/lukasz.kocewiak.eu\/blog\/?p=225"},"modified":"2012-10-05T16:02:38","modified_gmt":"2012-10-05T15:02:38","slug":"how-to-adjust-figures-in-matlab","status":"publish","type":"post","link":"https:\/\/lukasz.kocewiak.eu\/blog\/2012\/10\/04\/how-to-adjust-figures-in-matlab\/","title":{"rendered":"How to adjust figures in Matlab?"},"content":{"rendered":"<p>I was asked few times about possible adjustment of figures in Matlab. Many times there is simply a need to change slightly the default view in order to align with the template in our publication, book, etc. Thus I will try to show few parameters that can easily adjust the view according to our expectations.<\/p>\n<p>Fortunately in Matlab there is an extended flexibility of doing that. I need to admit that it is much more convenient to edit figures in Matlab than in other engineering tools (e.g. LabVIEW, PSCAD, PowerFactory, etc.). Therefore I personally export all of my results into Matlab and later adjust.<\/p>\n<p>Let me explain how to obtain the following figures. As one can see the figures present the same result but slightly in a different way. I do not need to mention that nicely presented research results can easily attract broader audience. Hence even in the conservative scientific world it is of great importance to be able selling our findings.<\/p>\n<p><a href=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-2D.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-230\" title=\"Kocewiak-Notch-Filter-2D\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-2D-300x217.png\" alt=\"Notch Filter - Bode Plot\" width=\"300\" height=\"217\" srcset=\"https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-2D-300x217.png 300w, https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-2D-1024x741.png 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<a href=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-3D.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-234\" title=\"Kocewiak-Notch-Filter-3D\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-3D-300x217.png\" alt=\"Notch Filter - 3D Phase\" width=\"300\" height=\"217\" srcset=\"https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-3D-300x217.png 300w, https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2012\/10\/Kocewiak-Notch-Filter-3D-1024x741.png 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The figures above show the variation of notch filter depending on the quality factor. The filter is tuned for 100Hz and included in synchronous reference frame and afterwards represented in natural\/stationary reference frame. Thus the resonant peaks are shifted \u00b150Hz. The notch filter transfer function is expressed in the following way.<\/p>\n<h3><p style='text-align:center;'><span class='MathJax_Preview'><img src='https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/latex\/cache\/tex_8cabb4cfde5ccaea122156604519ceb7.gif' style='vertical-align: middle; border: none;' class='tex' alt=\"\" \/><\/span><script type='math\/tex;  mode=display'><\/script><\/p><\/h3>\n<p>Such figures can be obtained by using the following code. Please note that also Control System Toolbox is needed to obtain the frequency response of the notch filter.<\/p>\n<pre><span style=\"color: #008000;\">% Prepare workspace<\/span>\r\nclc, clear(<span style=\"color: #800080;\">'all'<\/span>), close(<span style=\"color: #800080;\">'all'<\/span>),\r\n<span style=\"color: #008000;\">% Define font parameters<\/span>\r\nfontname= <span style=\"color: #800080;\">'Cambria'<\/span>;\r\nset(0,<span style=\"color: #800080;\">'defaultaxesfontname'<\/span>,fontname);\r\nset(0,<span style=\"color: #800080;\">'defaulttextfontname'<\/span>,fontname);\r\nfontsize= 10;\r\nset(0,<span style=\"color: #800080;\">'defaultaxesfontsize'<\/span>,fontsize);\r\nset(0,<span style=\"color: #800080;\">'defaulttextfontsize'<\/span>,fontsize);\r\n<span style=\"color: #008000;\">% Get screen resolution<\/span>\r\nscrsz= get(0,<span style=\"color: #800080;\">'ScreenSize'<\/span>);\r\n\r\n<span style=\"color: #008000;\">%% Notch filter<\/span>\r\n<span style=\"color: #008000;\">% Define frequency parameters<\/span>\r\nf= 50;                    <span style=\"color: #008000;\">% Grid frequency [Hz]<\/span>\r\nomegaO= 2*pi*f;           <span style=\"color: #008000;\">% Angular frequency [rad\/s]<\/span>\r\nomegaN= 2*omegaO;         <span style=\"color: #008000;\">% Resonant frequency [rad\/s]<\/span>\r\nstep= 0.1;                <span style=\"color: #008000;\">% Frequency step [Hz]<\/span>\r\nfrequencySeries= 1:step:200;\r\nomegaSeries= 2*pi*frequencySeries;\r\n<span style=\"color: #008000;\">% Construct transfer function<\/span>\r\ns= tf(<span style=\"color: #800080;\">'s'<\/span>);\r\nsN= s-1i*omegaO;\r\nsP= s+1i*omegaO;\r\n<span style=\"color: #008000;\">% Allocate memory<\/span>\r\nfirstIndex= 1; lastIndex= 30; k= 1;\r\nsurfTf= zeros(length(frequencySeries),lastIndex);\r\nmap= zeros(lastIndex,3);\r\n\r\n<span style=\"color: #008000;\">%% Display results<\/span>\r\n<span style=\"color: #008000;\">% Initiate figure<\/span>\r\nf1= figure(<span style=\"color: #800080;\">'Name'<\/span>,<span style=\"color: #800080;\">'Transfer Function Plot'<\/span>,...\r\n<span style=\"color: #800080;\">'Position'<\/span>,[scrsz(3)*0.2 scrsz(4)*0.2 scrsz(3)*0.35 scrsz(4)*0.45]);\r\nhold('on'),\r\nfor index=firstIndex:k:lastIndex,\r\n     Qn= 100\/sqrt(2); Qd= index+5;          <span style=\"color: #008000;\"> % Quality factor<\/span>\r\n     GnN= (sN^2+omegaN*sN\/Qn+omegaN^2)\/(sN^2+omegaN*sN\/Qd+omegaN^2);\r\n     GnP= (sP^2+omegaN*sP\/Qn+omegaN^2)\/(sP^2+omegaN*sP\/Qd+omegaN^2);\r\n     Gn= 1\/2*(GnP+GnN);                      <span style=\"color: #008000;\">% From SRF to NRF<\/span>\r\n     [magGn,phaseGn]= bode(Gn,omegaSeries);  <span style=\"color: #008000;\">% Frequency response<\/span>\r\n     GnCplx= magGn.*exp(1i*phaseGn);\r\n     surfTf(:,index)= GnCplx(:);\r\n     sub1= subplot(2,1,1,<span style=\"color: #800080;\">'Parent'<\/span>,f1);box(sub1,<span style=\"color: #800080;\">'on'<\/span>),hold(sub1,<span style=\"color: #800080;\">'all'<\/span>),\r\n     plot(frequencySeries,abs(GnCplx(:)),...\r\n          <span style=\"color: #800080;\">'Color'<\/span>,[0 1-index\/lastIndex index\/lastIndex]),\r\n          ylabel(<span style=\"color: #800080;\">'|{\\itG_{notch}}| [abs]'<\/span>),\r\n          xlim([min(frequencySeries) max(frequencySeries)]),\r\n          ylim([0.5 1.02]),hold(<span style=\"color: #800080;\">'on'<\/span>),grid(<span style=\"color: #800080;\">'off'<\/span>),\r\n     sub2= subplot(2,1,2,<span style=\"color: #800080;\">'Parent'<\/span>,f1);box(sub2,<span style=\"color: #800080;\">'on'<\/span>),hold(sub2,<span style=\"color: #800080;\">'all'<\/span>),\r\n     plot(frequencySeries,180*unwrap(angle(GnCplx(:)))\/pi,...\r\n          <span style=\"color: #800080;\">'Color'<\/span>,[0 1-index\/lastIndex index\/lastIndex]),\r\n          xlim([min(frequencySeries) max(frequencySeries)]),\r\n          ylim([-1100 1300]),hold('on'),grid('off'),\r\n          ylabel(<span style=\"color: #800080;\">'\\angle{\\it{G_{notch}}} [\\circ]'<\/span>),xlabel(<span style=\"color: #800080;\">'{\\itf} [Hz]'<\/span>),\r\n     map(index,:)= [0 1-index\/lastIndex index\/lastIndex];\r\nend\r\nc1= colorbar(<span style=\"color: #800080;\">'peer'<\/span>,sub1,<span style=\"color: #800080;\">'East'<\/span>);colormap(map),\r\nset(c1,<span style=\"color: #800080;\">'YTickMode'<\/span>,<span style=\"color: #800080;\">'manual'<\/span>,<span style=\"color: #800080;\">'YTickLabelMode'<\/span>,<span style=\"color: #800080;\">'manual'<\/span>,...\r\n<span style=\"color: #800080;\"> 'YTick'<\/span>,[firstIndex; floor((lastIndex-firstIndex)\/2); lastIndex],...\r\n<span style=\"color: #800080;\"> 'YTickLabel'<\/span>,[firstIndex+5; floor((lastIndex-firstIndex)\/2)+5; lastIndex+5]),\r\nhold(<span style=\"color: #800080;\">'off'<\/span>),\r\n\r\nf2= figure(<span style=\"color: #800080;\">'Name'<\/span>,<span style=\"color: #800080;\">'Impedance Angle'<\/span>,...\r\n     <span style=\"color: #800080;\">'Position'<\/span>,[scrsz(3)*0.2 scrsz(4)*0.2 scrsz(3)*0.35 scrsz(4)*0.45]);\r\nax2= axes(<span style=\"color: #800080;\">'Parent'<\/span>,f2);grid(ax2,<span style=\"color: #800080;\">'on'<\/span>),hold(ax2,<span style=\"color: #800080;\">'all'<\/span>),\r\nmesh(180*unwrap(angle(surfTf))\/pi),zlabel(<span style=\"color: #800080;\">'\\angle{\\it{G_{notch}}} [\\circ]'<\/span>),\r\n     ylabel(<span style=\"color: #800080;\">'{\\itf} [Hz]'<\/span>),xlabel(<span style=\"color: #800080;\">'{\\itQ_n} '<\/span>,<span style=\"color: #800080;\">'Rotation'<\/span>,322),view([60 40]),\r\nset(gca,<span style=\"color: #800080;\">'XTick'<\/span>,[firstIndex; floor((lastIndex-firstIndex)\/2); lastIndex],...\r\n<span style=\"color: #800080;\"> 'XTickLabel'<\/span>,[firstIndex+5; floor((lastIndex-firstIndex)\/2)+5; lastIndex+5],...\r\n<span style=\"color: #800080;\"> 'YTick'<\/span>,1:50\/step:length(frequencySeries),...\r\n<span style=\"color: #800080;\"> 'YTickLabel'<\/span>,min(frequencySeries):50:max(frequencySeries)),<\/pre>\n<p>Feel free to use and modify included Matlab code. I am also looking forward to hear from you in case of any suggestions and comments.<\/p>\n<div class='shareinpost'><ul class=\"socialwrap row\"><li class=\"iconOnly\"><a rel=\"nofollow\" target=\"_blank\" href=\"http:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Flukasz.kocewiak.eu%2Fblog%2F2012%2F10%2F04%2Fhow-to-adjust-figures-in-matlab%2F&amp;t=How+to+adjust+figures+in+Matlab%3F\" title=\"Recommend this post : How to adjust figures in Matlab? on Facebook\" ><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-275px 0px\" class=\"image-24\" width=\"24\" alt=\"facebook\"\/> <span class=\"head\">Recommend on Facebook<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"nofollow\" target=\"_blank\" href=\"http:\/\/www.linkedin.com\/shareArticle?mini=true&amp;url=https%3A%2F%2Flukasz.kocewiak.eu%2Fblog%2F2012%2F10%2F04%2Fhow-to-adjust-figures-in-matlab%2F&amp;title=How+to+adjust+figures+in+Matlab%3F&amp;&amp;summary=I+was+asked+few+times+about+possible+adjustment+of+figures+in+Matlab.+Many+times+there+is+simply+a+need+to+change+slightly+the+default+view+in+order+to+align+with+the+template+in+our+publication%2C+book%2C+etc.+Thus+I+will+try+to+show+few+parameters+that+can+easily+adjust+the+view+according+to+our+expectations.%0D%0A%0D%0AFortunat\" title=\"Share this post : How to adjust figures in Matlab? on Linkedin\" ><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-675px 0px\" class=\"image-24\" width=\"24\" alt=\"linkedin\"\/> <span class=\"head\">Share on Linkedin<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"nofollow\" target=\"_blank\" href=\"http:\/\/twitter.com\/home\/?status=https%3A%2F%2Flukasz.kocewiak.eu%2Fblog%2F2012%2F10%2F04%2Fhow-to-adjust-figures-in-matlab%2F\" title=\"Tweet this post : How to adjust figures in Matlab? on Twitter\" ><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-1325px 0px\" class=\"image-24\"  width=\"24\"  alt=\"twitter\"\/> <span class=\"head\">Tweet about it<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"_self\" href=\"https:\/\/lukasz.kocewiak.eu\/blog\/2012\/10\/04\/how-to-adjust-figures-in-matlab\/feed\" title=\"Follow this post : How to adjust figures in Matlab? comments\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\"  width=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-1100px 0px\" class=\"image-24\"  alt=\"rss\" \/> <span class=\"head\">Subscribe to the comments on this post<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"_self\" href=\"mailto:?subject=\u0141ukasz%20Kocewiak%20:%20How%20to%20adjust%20figures%20in%20Matlab?&amp;body=here%20is%20a%20link%20to%20a%20site%20I%20really%20like.%20%20%20https:\/\/lukasz.kocewiak.eu\/blog\/2012\/10\/04\/how-to-adjust-figures-in-matlab\/\" title=\"Tell a friend about this post : How to adjust figures in Matlab? \"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\"  width=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-250px 0px\" class=\"image-24\"  alt=\"email\" \/> <span class=\"head\">Tell a friend<\/span><\/a><\/li><\/ul><div class=\"clean\"><\/div> <\/div>","protected":false},"excerpt":{"rendered":"<p>I was asked few times about possible adjustment of figures in Matlab. Many times there is simply a need to change slightly the default view in order to align with the template in our publication, book, etc. Thus I will try to show few parameters that can easily adjust the view according to our expectations. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[12,7],"class_list":["post-225","post","type-post","status-publish","format-standard","hentry","category-software","tag-3d-figure","tag-matlab"],"_links":{"self":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts\/225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/comments?post=225"}],"version-history":[{"count":32,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts\/225\/revisions"}],"predecessor-version":[{"id":260,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts\/225\/revisions\/260"}],"wp:attachment":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/media?parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/categories?post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/tags?post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}