作者PageRank ()
看板MATLAB
标题[问题] .NET 叫用 MATLAB DLL 的提示讯息
时间Mon Jan 13 22:40:04 2014
各位先进好
1. 我使用 MATLAB Builder NE 将我要用的 MATLAB 函式编译成 DLL 档
2. 在 Visual Studio 2010 的环境中使用 C# 叫用此 DLL。
使用的 MATLAB 函数为 lsqcurvefit
程式码为 MATLAB 线上文件的范例,请参考说明中的 Example
http://www.mathworks.com/help/optim/ug/lsqcurvefit.html
或是
---------------------------
myfun.m
function F = myfun(x,xdata)
F = x(1)*exp(x(2)*xdata);
---------------------------
Untitled2.m
% Assume you determined xdata and ydata experimentally
xdata = ...
[0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3];
ydata = ...
[455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5];
x0 = [100; -1] % Starting guess
[x,resnorm] = lsqcurvefit(@myfun,x0,xdata,ydata);
--------------------------------------------------------
在 MATLAB 运行中出现下列提示讯息 (正常的)
-----------------------------------------
Local minimum possible.
lsqcurvefit stopped because the final change in the sum of squares relative
to
its initial value is less than the default value of the function tolerance.
<stopping criteria details>
Optimization stopped because the relative sum of squares (r) is changing
by less than options.TolFun = 1.000000e-06.
-------------------------------------------
但是在 C# 运行中也出现此讯息
要如何让 C# 运行中不出现此讯息呢?
请赐教。
感谢在先。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.68.239.53
1F:→ PageRank:自问自答 在 MATLAB 中加上 01/13 23:25
2F:→ PageRank:opts = optimset('Display', 'off'); 01/13 23:25
3F:→ PageRank:并修改 lsqcurvefit(@myfun,x0,xdata,ydata,[],[],opts) 01/13 23:26