Part 1 gives an overview of Matlab Network manager . This screen cast shows how to create XOR network using Matlab Network Manager.
This part explains how to use Matlab Neural Network in c# windows application and limitation of Matlab complier with respect to 'sim' function.
Note:- Don't forget to watch next episode of this series, in which I have explained how to get around with 'sim' function compiler limitation and call Neural network from c# windows application
In this part I have explained how to get around with 'sim' function compiler limitation and call Neural network from c# windows application.
Showing posts with label matlab. Show all posts
Showing posts with label matlab. Show all posts
Monday, 4 May 2009
Monday, 2 March 2009
Developing Financial Applications using .Net & Matlab ( Part-1)
This video shows how we can use Algorithms written in matlab 'M' code can be used in .Net applications. (View the video in 'double size' resolution).
Matlab Code snippet
--------------------
function [ Price,AccruedInt ] = MyBndPrice(Yield, CouponRate, Settle,...
Maturity, Period, Basis)
[Price, AccruedInt] = bndprice(Yield, CouponRate, Settle,...
Maturity, Period, Basis);
end
.Net Code snippet
-------------------
private void btnBndPrice_Click(object sender, EventArgs e)
{
MWNumericArray yields = GetYields();
MWNumericArray coupon = new MWNumericArray(Convert.ToDouble(txtCoupon.Text) ) ;
MWNumericArray period = new MWNumericArray(cmbPeriod.SelectedIndex + 1 ) ;
MWNumericArray basis = new MWNumericArray(cmbBasis.SelectedIndex);
MWCharArray settlement = new MWCharArray(txtSettlement.Text);
MWCharArray maturity = new MWCharArray(txtMaturity.Text);
MyFinLib.MyFinLibclass finLib = new MyFinLib.MyFinLibclass();
MWArray[] result = finLib.MyBndPrice(2, yields, coupon, settlement, maturity, period, basis);
Display(result);
}
private double[] GetYields()
{
string[] yieldStr = txtYield.Text.Split(',');
double[] yields = new double[ yieldStr.Length ];
for (int i = 0; i < yieldStr.Length; i++)
yields[i] = Convert.ToDouble(yieldStr[i]);
return yields ;
}
private void Display(MWArray[] result)
{
DataTable dt = new DataTable();
dt.Columns.Add("Price");
dt.Columns.Add("Accrued Interest");
string[] price = result[0].ToString().Split('\n');
string[] accuredInt = result[1].ToString().Split('\n');
for (int i = 0; i < price.Length; i++)
{
DataRow row = dt.NewRow();
row[0] = price[i];
row[1] = accuredInt[i];
dt.Rows.Add(row);
}
dataGridView1.DataSource = dt;
}
Matlab Code snippet
--------------------
function [ Price,AccruedInt ] = MyBndPrice(Yield, CouponRate, Settle,...
Maturity, Period, Basis)
[Price, AccruedInt] = bndprice(Yield, CouponRate, Settle,...
Maturity, Period, Basis);
end
.Net Code snippet
-------------------
private void btnBndPrice_Click(object sender, EventArgs e)
{
MWNumericArray yields = GetYields();
MWNumericArray coupon = new MWNumericArray(Convert.ToDouble(txtCoupon.Text) ) ;
MWNumericArray period = new MWNumericArray(cmbPeriod.SelectedIndex + 1 ) ;
MWNumericArray basis = new MWNumericArray(cmbBasis.SelectedIndex);
MWCharArray settlement = new MWCharArray(txtSettlement.Text);
MWCharArray maturity = new MWCharArray(txtMaturity.Text);
MyFinLib.MyFinLibclass finLib = new MyFinLib.MyFinLibclass();
MWArray[] result = finLib.MyBndPrice(2, yields, coupon, settlement, maturity, period, basis);
Display(result);
}
private double[] GetYields()
{
string[] yieldStr = txtYield.Text.Split(',');
double[] yields = new double[ yieldStr.Length ];
for (int i = 0; i < yieldStr.Length; i++)
yields[i] = Convert.ToDouble(yieldStr[i]);
return yields ;
}
private void Display(MWArray[] result)
{
DataTable dt = new DataTable();
dt.Columns.Add("Price");
dt.Columns.Add("Accrued Interest");
string[] price = result[0].ToString().Split('\n');
string[] accuredInt = result[1].ToString().Split('\n');
for (int i = 0; i < price.Length; i++)
{
DataRow row = dt.NewRow();
row[0] = price[i];
row[1] = accuredInt[i];
dt.Rows.Add(row);
}
dataGridView1.DataSource = dt;
}
Subscribe to:
Posts (Atom)