Calling a C sharp function from Matlab

3 visualizaciones (últimos 30 días)
Maria Isabel
Maria Isabel el 23 de Nov. de 2012
Respondida: Priya Jeganathan el 15 de Sept. de 2021
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.

Respuestas (2)

Ken Atwell
Ken Atwell el 27 de Nov. de 2012
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 comentario
Shahidul Asif
Shahidul Asif el 8 de Mzo. de 2021
How do I expose the codes as you mentioned?

Iniciar sesión para comentar.


Priya Jeganathan
Priya Jeganathan el 15 de Sept. de 2021
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.

Categorías

Más información sobre Financial Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by