Rank: 1052 based on 104 downloads (last 30 days) and 11 files submitted
photo

Damith Senaratne

E-mail

Personal Profile:

I am a researcher in Wireless Communication with some programming background (My personal website is: http://www.damiths.info ).

Most of the m-files here are trivial yet useful tools, probably useable irrespective of the research field one works in. Please feel free to download any of the files in my collection, and provide me feedback so that I can improve. Thanks!

Professional Interests:
MIMO signal processing, wireless communication

 

Watch this Author's files

 

Files Posted by Damith View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Dec 2012 Screenshot ipanel Implements a controller panel to provide a primitive MATHEMATICA-'Manipulate'-like facility. Author: Damith Senaratne interactive graphics, interact, slider, checkbox, popupmenu, uicontrol 7 3
  • 5.0
5.0 | 2 ratings
22 Jun 2012 reorderLegend Re-orders the legend entries. Author: Damith Senaratne legend, reorder, rearrange 25 2
  • 5.0
5.0 | 1 rating
14 Jun 2012 rndvar Provides a MATLAB class for simulating random variables (RV). Author: Damith Senaratne random variable, monte carlo, mean, pdf, expectation 9 0
30 May 2012 pskdemodXOR Implements a demodulator object for M-PSK physical layer network coding. Author: Damith Senaratne demodulator, mpsk, psk, physical layer networ..., xor, communications 15 0
14 Oct 2011 circperm Computes a basic circulant permutation matrix raised to an arbitrary power. Author: Damith Senaratne circulant permutation... 8 0
Comments and Ratings by Damith View all
Updated File Comments Rating
08 Aug 2013 ipanel Implements a controller panel to provide a primitive MATHEMATICA-'Manipulate'-like facility. Author: Damith Senaratne

Just found that 'ipanel' crashes when trying to resize or use ipanel while panning a zoomed figure. This is because a child object of type 'uicontextmenu' is created under Figure and 'ipanel' tries to access its Units.
Replacing line 643: "hCh = get(this.hFigure,'Children');" with "hCh = findobj(this.hFigure,'type','axes');" would fix the bug.
I would include the bug fix in the next version of 'ipanel'.

06 May 2013 reorderLegend Re-orders the legend entries. Author: Damith Senaratne

@Kim, Get the handle to the desired axes and pass it as the second argument to reorderLegend. That should work.

Pls. try this example:

>> x = 0:.01:pi;
>> subplot(2,1,1); plot(x,sin(x),x,cos(x)); legend('sin(x)','cos(x)'); % first set of axes and curves
>> subplot(2,1,2); plot(x,sin(x).^2,x,cos(x).^2); legend('sin^2(x)','cos^2(x)'); % second set of axes and curves
>> ha = findobj(h,'Type','axes','Tag',''); % get the axes (legends are also axes but with 'Tag' == 'legend')
>> % ha is a stack; first element is the handle to the axes created last
>> reorderLegend([],ha(1)) % pass order == [] with the handle to get the indices
[1] cos^2(x)
[2] sin^2(x)
>> reorderLegend([1,2],ha(1)) % call the function with the desired order and the same handle

Hope this helps

16 Feb 2012 MeijerG A wrapper for MATLAB symbolic library implementation of the 'MeijerG' G^{m,n}_{p,q}(...|z) function. Author: Damith Senaratne

@noosa,
There should be ways around the problem. But I cannot say which one will work for you.

1. There may be a simple fix because you already know that MeijerG output is probably wrong for k=1. I am assuming your mathematical expressions are correct (please double check to make sure k=1 is a valid value).

Since most of the functions we deal with are smooth, you can add a small perturbation to the arguments of MeijerG (as I have done with argument 1 in the example) . Try k = 1 + some delta (e.g. 1e-5). You cannot make delta arbitrarily small because of the lower precision. But you should be able to find a reasonably small value that gives acceptable results. The problem could be with a different parameter of MeijerG and not k. If so, you'll have to follow a trial and error approach.

2. Does your MeijerG compute only a mere factor in each term of a summation? If so the problem could be the terms not getting properly canceled out because of lower precision of MeijerG output. You can check the value each term of the summation evaluates to and detect if that's the case. Solution is not straightforward. You'd probably have to reformulate the expression to avoid the problem.

Hope my answer helps.

14 Feb 2012 MeijerG A wrapper for MATLAB symbolic library implementation of the 'MeijerG' G^{m,n}_{p,q}(...|z) function. Author: Damith Senaratne

@noosa,
I haven't rigorously checked the output against maple or MATHEMATICA. However, I have tested the function with couple of examples. I have also used it to compute certain analytic (wireless communication) performance analysis results, and found them to agree with corresponding simulated values. But it is difficult to tell if the function produces accurate results all the time. The function merely invokes the MATLAB symbol engine (maple or mupad depending on the MATLAB version). So it shouldn't introduce errors, other than those caused in 'double'->'string' conversion.
Since you asked, I just tried my example on maple. The output I got (given below) seems to be consistent with what MATLAB function produces.

> evalf(MeijerG([[1, 1], []], [[1], [1]], 1));
MeijerG([[1.], []], [[1.], []], 1.)
> evalf(MeijerG([[1, 1], []], [[1], [1]], 2));
0.6666666667
> evalf(MeijerG([[1, 1], []], [[1], [1]], 3));
0.7500000001
> evalf(MeijerG([[1, 1], []], [[1], [1]], 1.00001));
0.5000025000 + 0. I

Hope this helps.

Comments and Ratings on Damith's Files View all
Updated File Comment by Comments Rating
12 Dec 2013 displayInline Displays a string inline in the MATLAB Command Window, overwriting any text it previously displayed. Author: Damith Senaratne tasdemir, kasim

Hi,

I use 'dispstat' function just for this purpose. It can update the previous output which is a missing function of default 'disp'. Very simple to use. It can be downloaded from here:

http://www.mathworks.com/matlabcentral/fileexchange/44673

***Sample usage:
dispstat('','init'); % One time only initialization
dispstat(sprintf('Begining the process...'),'keepthis','timestamp');
for i = 97:100
dispstat(sprintf('Progress %d%%',i),'timestamp');
%doing some heavy stuff here
end
dispstat('Finished.','keepprev');

***Output:
11:25:37 Begining the process...
11:25:37 Progress 100%
Finished.

All the best

12 Sep 2013 ipanel Implements a controller panel to provide a primitive MATHEMATICA-'Manipulate'-like facility. Author: Damith Senaratne Jonathan

This is great! I agree with Jesus. It would be awesome if this update in real time, but maybe that is very difficult to do.

08 Aug 2013 ipanel Implements a controller panel to provide a primitive MATHEMATICA-'Manipulate'-like facility. Author: Damith Senaratne Senaratne, Damith

Just found that 'ipanel' crashes when trying to resize or use ipanel while panning a zoomed figure. This is because a child object of type 'uicontextmenu' is created under Figure and 'ipanel' tries to access its Units.
Replacing line 643: "hCh = get(this.hFigure,'Children');" with "hCh = findobj(this.hFigure,'type','axes');" would fix the bug.
I would include the bug fix in the next version of 'ipanel'.

06 May 2013 reorderLegend Re-orders the legend entries. Author: Damith Senaratne Senaratne, Damith

@Kim, Get the handle to the desired axes and pass it as the second argument to reorderLegend. That should work.

Pls. try this example:

>> x = 0:.01:pi;
>> subplot(2,1,1); plot(x,sin(x),x,cos(x)); legend('sin(x)','cos(x)'); % first set of axes and curves
>> subplot(2,1,2); plot(x,sin(x).^2,x,cos(x).^2); legend('sin^2(x)','cos^2(x)'); % second set of axes and curves
>> ha = findobj(h,'Type','axes','Tag',''); % get the axes (legends are also axes but with 'Tag' == 'legend')
>> % ha is a stack; first element is the handle to the axes created last
>> reorderLegend([],ha(1)) % pass order == [] with the handle to get the indices
[1] cos^2(x)
[2] sin^2(x)
>> reorderLegend([1,2],ha(1)) % call the function with the desired order and the same handle

Hope this helps

01 May 2013 reorderLegend Re-orders the legend entries. Author: Damith Senaratne DiGiovanni, Kim

Excellent!!
Now, how to do this when there are multiple axes on a chart...

Contact us