mbuild -setup
. We agree with everything and choose the medium we need, in our case it is MVS 2008 SP1. We get something similar:Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2010a\sys\lcc
[2] Microsoft Visual C++ 2008 SP1 in C:\Program Files\Microsoft Visual Studio 9.0
[0] None
Compiler: 2
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 SP1
Location: C:\Program Files\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
Done
. All - the linker is configured.function res=plane(strfunc,vx0,vx1,vy0,vy1,h)
vx=vx0:h:vx1;
vy=vy0:h:vy1;
figure(1)
res=ezsurfc(strfunc,vx,vy);
end
strfunc
), initial and final values ​​of the plane boundary vectors (v x0,vx1,vy0,vy1
), grid spacing ( h
) and returns the descriptor ( res
).function
(preferably end
) and be a separate m-file.deploytool
in the command window MATLAB'a deploytool
. Create a new .NET Assembly project MATLABplane, specify the location.using MathWorks.MATLAB.NET.Utility;
using MathWorks.MATLAB.NET.Arrays;
using MATLABplane;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using MathWorks.MATLAB.NET.Utility; using MathWorks.MATLAB.NET.Arrays; using MATLABplane; namespace planeApp { public partial class Form1 : Form { public Form1() { InitializeComponent(); button1.Click += new EventHandler(button1_Click);// button2.Click += new EventHandler(button2_Click); } double x0, x1, y0, y1, h; // string func, s_x0, s_x1, s_y0, s_y1, s_h; MWArray[] res = null; // plane MWNumericArray descriptor = null; // private void button1_Click(object sender, EventArgs e)// { try { func = textBox1.Text; // TextBox s_x0 = textBox2.Text; s_x1 = textBox3.Text; s_y0 = textBox4.Text; s_y1 = textBox5.Text; s_h = textBox6.Text; MWCharArray mw_func = new MWCharArray(func);// MWCharArray x0 = Convert.ToDouble(s_x0); // string double x1 = Convert.ToDouble(s_x1); y0 = Convert.ToDouble(s_y0); y1 = Convert.ToDouble(s_y1); h = Convert.ToDouble(s_h); planeClass obj_plane = new planeClass(); // res = obj_plane.plane(1, mw_func, x0, x1, y0, y1, h);// plane, - - descriptor = (MWNumericArray)res[0]; // MWArray MWNumericArray double[,] d_descriptor = (double[,])descriptor.ToArray(MWArrayComponent.Real);// MWNUmericArray double for (int i = 0; i < d_descriptor.Length; i++)// d_descriptor RichBox { richTextBox1.Text += i.ToString() + '\t'; richTextBox1.Text += d_descriptor[i, 0].ToString("0.000") + '\n';// double string } } catch (Exception ex)// { System.Windows.Forms.MessageBox.Show(ex.Message); } } private void button2_Click(object sender, EventArgs e) { richTextBox1.Text = string.Empty;// RichBox res = null;// descriptor = null; } } }
Source: https://habr.com/ru/post/132487/
All Articles