Calling a C sharp function from Matlab
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (2)
Ken Atwell
le 27 Nov 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 commentaire
Priya Jeganathan
le 15 Sep 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.
0 commentaires
Voir également
Catégories
En savoir plus sur MATLAB Compiler SDK dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!