{"id":331977,"date":"2022-04-15T15:00:18","date_gmt":"2022-04-15T15:00:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331977"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331977","title":{"rendered":"<span>\u041a\u0430\u043a \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c MATLAB DLL \u0438 C#<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f m-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 Curve Fitting Toolbox \u0432 \u043a\u0430\u043a\u0443\u044e \u043d\u0438\u0431\u0443\u0434\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044e\u044e \u0441\u0432\u043e\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c dll-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0440\u0430\u0437\u0443\u043c\u0435\u043d\u0438\u044e. <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f &#8212; \u043a\u0440\u0430\u0442\u043a\u043e \u043f\u043e \u0448\u0430\u0433\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b: <\/p>\n<ul>\n<li>\n<p>MATLAB 2022a<\/p>\n<ul>\n<li>\n<p>MATLAB Compiler Runtime<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>VS Community C# 2020<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<h2>\u0421\u0431\u043e\u0440\u043a\u0430 DLL<\/h2>\n<p>\u0412 \u043c\u0430\u0442\u043b\u0430\u0431\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c m-\u0444\u0430\u0439\u043b \u0441 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439<\/p>\n<pre><code>function koeffs = solve_lsm(n,x,y,wts)          str = strcat('poly',num2str(n));     opts = fitoptions('Weights',wts);     ftype = fittype(str);     result = fit(x',y',ftype,opts);     koeffs = coeffvalues(result)';  end<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u0430\u0442\u043b\u0430\u0431\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c deploytool, \u0432 \u043e\u043a\u043e\u0448\u043a\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c Library Compiler<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/320\/449\/c3b\/320449c3b8f3b410d7628a78aa95bcc4.png\" width=\"538\" height=\"274\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/320\/449\/c3b\/320449c3b8f3b410d7628a78aa95bcc4.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u043c\u0441\u044f \u043e\u043a\u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0432\u0435\u0440\u0441\u0438\u044f, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0418\u0437 \u0432\u0430\u0436\u043d\u043e\u0433\u043e:<\/p>\n<ul>\n<li>\n<p>\u041e\u043a\u043e\u0448\u043a\u043e TYPE \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c &#171;.NET Assembly&#187;<\/p>\n<\/li>\n<li>\n<p>\u041e\u043a\u043e\u0448\u043a\u043e EXPORTED FUNCTIONS \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c m-\u0444\u0430\u0439\u043b\u044b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043d\u0438\u0437\u0443 \u043f\u043e\u043b\u0435 Class Name \u0437\u0430\u0434\u0430\u0435\u043c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 Matlab Runtime<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/32e\/3dc\/bef\/32e3dcbef9bce1fa4012e420de4ed31d.png\" width=\"984\" height=\"835\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/32e\/3dc\/bef\/32e3dcbef9bce1fa4012e420de4ed31d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0433\u0430\u043b\u043e\u0447\u043a\u0443 Package<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2af\/b42\/28f\/2afb4228f10fca6ea4b13c784bad5e2a.png\" width=\"384\" height=\"219\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2af\/b42\/28f\/2afb4228f10fca6ea4b13c784bad5e2a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0430\u043f\u043a\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f98\/8d0\/51d\/f988d051d10a54283e3cf19efab607bc.png\" width=\"211\" height=\"103\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f98\/8d0\/51d\/f988d051d10a54283e3cf19efab607bc.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 for_redistribution \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c MyAppInstaller_web.exe, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Matlab Runtime, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u0430\u0448\u0438\u043c \u041f\u041e \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 DLL \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Matlab Runtime \u0438 Framework.<\/p>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DLL \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 VS C# 2020<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (.NET Framework)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/468\/be2\/1b5\/468be21b59d8bccca783ca687869361e.png\" width=\"520\" height=\"98\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/468\/be2\/1b5\/468be21b59d8bccca783ca687869361e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u043c\u0438 LSMLib \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u0443\u044e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 Matlab \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 MVArray. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0443\u0442: MATLAB\\R2022a\\toolbox\\dotnetbuilder\\bin\\win64\\v4.0\\   <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/390\/c27\/f40\/390c27f407f91588b91fb807a7ff832c.png\" width=\"253\" height=\"331\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/390\/c27\/f40\/390c27f407f91588b91fb807a7ff832c.png\"\/><figcaption><\/figcaption><\/figure>\n<pre><code>using MathWorks.MATLAB.NET.Arrays; using MathWorks.MATLAB.NET.Utility; using LSMLib;<\/code><\/pre>\n<p>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code>\/\/\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c double n = 3; double[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; double[] y = {3,5,4,6,7,7,4,5,6,7,8,9,6,6,7}; double[] wts = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};                         \/\/\u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LSMLib.LSMLib test = new LSMLib.LSMLib(); MWArray res = test.solve_lsm((MWArray)n, (MWNumericArray)x, \\ (MWNumericArray)y, (MWNumericArray)wts);<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043c\u0430\u0442\u043b\u0430\u0431\u0430 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre><code>\/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0438\u0445 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a var array = (MWNumericArray)res;  var dd = (double[,])array.ToArray(MWArrayComponent.Real);  List&lt;double> koeffs = new List&lt;double>(); for (int i = 0; i &lt; dd.Length; i++) { koeffs.Add(dd[i, 0]); }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u0443, \u0443 \u043c\u0435\u043d\u044f x64<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u043d\u0430 <a href=\"https:\/\/github.com\/MariaKudryashova\/mathdll\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a><\/p>\n<p>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/132487\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/132487\/<\/a><\/p>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=5qDkr4GKwAw\" rel=\"noopener noreferrer nofollow\">https:\/\/www.youtube.com\/watch?v=5qDkr4GKwAw<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/661223\/\"> https:\/\/habr.com\/ru\/post\/661223\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f m-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 Curve Fitting Toolbox \u0432 \u043a\u0430\u043a\u0443\u044e \u043d\u0438\u0431\u0443\u0434\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044e\u044e \u0441\u0432\u043e\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c dll-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0440\u0430\u0437\u0443\u043c\u0435\u043d\u0438\u044e. <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f &#8212; \u043a\u0440\u0430\u0442\u043a\u043e \u043f\u043e \u0448\u0430\u0433\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b: <\/p>\n<ul>\n<li>\n<p>MATLAB 2022a<\/p>\n<ul>\n<li>\n<p>MATLAB Compiler Runtime<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>VS Community C# 2020<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<h2>\u0421\u0431\u043e\u0440\u043a\u0430 DLL<\/h2>\n<p>\u0412 \u043c\u0430\u0442\u043b\u0430\u0431\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c m-\u0444\u0430\u0439\u043b \u0441 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439<\/p>\n<pre><code>function koeffs = solve_lsm(n,x,y,wts)          str = strcat('poly',num2str(n));     opts = fitoptions('Weights',wts);     ftype = fittype(str);     result = fit(x',y',ftype,opts);     koeffs = coeffvalues(result)';  end<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u0430\u0442\u043b\u0430\u0431\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c deploytool, \u0432 \u043e\u043a\u043e\u0448\u043a\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c Library Compiler<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u043c\u0441\u044f \u043e\u043a\u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0432\u0435\u0440\u0441\u0438\u044f, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0418\u0437 \u0432\u0430\u0436\u043d\u043e\u0433\u043e:<\/p>\n<ul>\n<li>\n<p>\u041e\u043a\u043e\u0448\u043a\u043e TYPE \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c &#171;.NET Assembly&#187;<\/p>\n<\/li>\n<li>\n<p>\u041e\u043a\u043e\u0448\u043a\u043e EXPORTED FUNCTIONS \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c m-\u0444\u0430\u0439\u043b\u044b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043d\u0438\u0437\u0443 \u043f\u043e\u043b\u0435 Class Name \u0437\u0430\u0434\u0430\u0435\u043c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 Matlab Runtime<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0433\u0430\u043b\u043e\u0447\u043a\u0443 Package<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0430\u043f\u043a\u0438:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 for_redistribution \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c MyAppInstaller_web.exe, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Matlab Runtime, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u0430\u0448\u0438\u043c \u041f\u041e \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 DLL \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Matlab Runtime \u0438 Framework.<\/p>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DLL \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 VS C# 2020<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (.NET Framework)<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u043c\u0438 LSMLib \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u0443\u044e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 Matlab \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 MVArray. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0443\u0442: MATLAB\\R2022a\\toolbox\\dotnetbuilder\\bin\\win64\\v4.0\\   <\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<pre><code>using MathWorks.MATLAB.NET.Arrays; using MathWorks.MATLAB.NET.Utility; using LSMLib;<\/code><\/pre>\n<p>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code>\/\/\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c double n = 3; double[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; double[] y = {3,5,4,6,7,7,4,5,6,7,8,9,6,6,7}; double[] wts = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};                         \/\/\u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LSMLib.LSMLib test = new LSMLib.LSMLib(); MWArray res = test.solve_lsm((MWArray)n, (MWNumericArray)x, \\ (MWNumericArray)y, (MWNumericArray)wts);<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043c\u0430\u0442\u043b\u0430\u0431\u0430 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre><code>\/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0438\u0445 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a var array = (MWNumericArray)res;  var dd = (double[,])array.ToArray(MWArrayComponent.Real);  List&lt;double> koeffs = new List&lt;double>(); for (int i = 0; i &lt; dd.Length; i++) { koeffs.Add(dd[i, 0]); }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u0443, \u0443 \u043c\u0435\u043d\u044f x64<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u043d\u0430 <a href=\"https:\/\/github.com\/MariaKudryashova\/mathdll\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a><\/p>\n<p>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/132487\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/132487\/<\/a><\/p>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=5qDkr4GKwAw\" rel=\"noopener noreferrer nofollow\">https:\/\/www.youtube.com\/watch?v=5qDkr4GKwAw<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/661223\/\"> https:\/\/habr.com\/ru\/post\/661223\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331977","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331977"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331977\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}