Calling a C sharp function from Matlab

3 ビュー (過去 30 日間)
Maria Isabel
Maria Isabel 2012 年 11 月 23 日
回答済み: Priya Jeganathan 2021 年 9 月 15 日
I´m developing a project with Matlab but I need to link it with csharp functions (speed requirements). Can you please explain me how to do it? Do you have any example? I think is not necessary to use Mex function, can you please confirm?
Thank you in advanced for your support.

回答 (2 件)

Ken Atwell
Ken Atwell 2012 年 11 月 27 日
If you stick your C# code into a .NET library, you can call it from MATLAB. You should not need to write MEX glue code. Take a look here:
  1 件のコメント
Shahidul Asif
Shahidul Asif 2021 年 3 月 8 日
How do I expose the codes as you mentioned?

サインインしてコメントする。


Priya Jeganathan
Priya Jeganathan 2021 年 9 月 15 日
Start
{
float daily, total_daily=0, total_averge = 0;% defining the variable
float highest = 0;
int average = 0;
int final_count = 0;
string rootFile = @"D:\External Work\2018-January-Averages-AGLHAL.txt"; % Opening the text file
string[] dir = File.ReadAllLines(rootFile);%Reading the text file values
for (int i = 0; i < dir.Length; i++)
{
daily = float.Parse(dir[i]); %place the daily averages into a 1D array.
highest = daily > highest ? daily : highest;
if (daily > 0.00)
{
average++;
}
total_daily = total_daily + daily;
}
total_averge = total_daily / average;
for (int i = 0; i < dir.Length; i++)
{
if (float.Parse(dir[i]) > total_averge)
{
final_count++;
}
}
disp(" Summary Information for AGLHAL");
disp(" File Name : 2018-January-Averages-AGLHAL.txt");
if (highest == 0.00 && average == 0) //if there are no daily averages above 0.
{
disp("Max :" + highest.ToString("0.#"));
disp("Total Avaerage :" + average);
}
else
{
disp("Maximum Daily Average=" + highest.ToString("0.#")); //Maximum Daily Average
disp("Number of Daily Averages > 0 =" + average); //Number of Daily Averages > 0
disp("Average of Daily Averages that are > 0=" + total_averge.ToString("0.##")); //Average of Daily Averages that are > 0
disp("Number of Daily Averages > Average=" + final_count); //Average of Daily Averages that are > 0
}
input();
}
Until fileVariable.endOfFile // closing the text file
End.

カテゴリ

Help Center および File ExchangeFinancial Toolbox についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by