小编Jac*_*ckA的帖子

无法在 C# 中转换 Matlab COM 对象

大家好,我正在尝试从 C# 应用程序控制 Matlab,所以我选择了 COM 服务器解决方案,但是我无法让它工作。

首先,我使用comserver('register','User','all')Matlab 命令窗口将我的 Matlab 注册为 COM 服务器。然后我在我的 C# 项目中引用了这个服务器。

之后,我实现了简单的 C# 代码来访问我编写的 Matlab 函数:

        // Create the MATLAB instance 
        MLApp.MLApp matlab = new MLApp.MLApp(); // Where the code returns an error

        // Change to the directory where the function is located 
        matlab.Execute(@"cd C:\Users\jar\Downloads\");

        // Define the output 
        object result = null;

        // Call the MATLAB function myfunc
        matlab.Feval("traj2D_image",1, out result,
                                        ParametresBalayage.NomFichier,
                                        ParametresBalayage.LongueurBalayage,
                                        ParametresBalayage.NbBalayage,
                                        ParametresBalayage.PasBalayage,
                                        ParametresBalayage.DecalageBalayage,
                                        ParametresBalayage.DecalageStries,
                                        ParametresBalayage.Vitesse,
                                        sens);

        // Display result 
        object[] res …
Run Code Online (Sandbox Code Playgroud)

c# com matlab

5
推荐指数
0
解决办法
148
查看次数

Delete all empty cells in a cell array

I have an array of cells in which I want to select 3 lines so I used this temp = testresults(13:15,1:end).

The array being bigger, I get a lot of empty cells

{'Summary Test Re…'}    {'Overall'   }    {0×0 char          }    {'OVP Transition …'}    {0×0 char}    {0×0 char}    {0×0 char}    {0×0 char}    {0×0 char}    {0×0 char}
{'Pass/Fail'       }    {'Passed'    }    {'No Transition t…'}    {'Passed'          }    {0×0 char}    {0×0 char}    {0×0 char}    {0×0 char}    {0×0 char}    {0×0 char}
{'Failed cases'    } …
Run Code Online (Sandbox Code Playgroud)

arrays matlab cell-array

2
推荐指数
1
解决办法
62
查看次数

标签 统计

matlab ×2

arrays ×1

c# ×1

cell-array ×1

com ×1