MATLAB语言转化为VC++语言

% Program 2-5
% fade.m
%
% Generate Rayleigh fading
%
function [iout,qout,ramp,rcos,rsin]=fade(idata,qdata,...
nsamp,tstp,fd,no,counter,flat)
%********************** variables *********************
% idata : input Ich data
% qdata : input Qch data
% iout : output Ich data
% qout : output Qch data
% ramp : Amplitude contaminated by fading
% rcos : Cosine value contaminated by fading
% rsin : Cosine value contaminated by fading
% nsamp : Number of samples to be simulated
% tstp : Minimum time resolution
% fd : maximum doppler frequency
% no : number of waves in order to generate fading
% counter : fading counter
% flat : flat fading or not
% (1-flat (only amplitude is fluctuated),0-normal
% (phase and amplitude are fluctutated))
%******************************************************
if fd ~= 0.0
ac0 = sqrt(1.0 ./ (2.0.*(no + 1)));
% power normalized constant(ich)
as0 = sqrt(1.0 ./ (2.0.*no));
% power normalized constant(qch)
ic0 = counter;
% fading counter
pai = 3.14159265;
wm = 2.0.*pai.*fd;
n = 4.*no + 2;
ts = tstp;
wmts = wm.*ts;
paino = pai./no;
xc=zeros(1,nsamp);
xs=zeros(1,nsamp);
ic=[1:nsamp]+ic0;
for nn=1:no
cwn = cos( cos(2.0.*pai.*nn./n).*ic.*wmts );
xc = xc + cos(paino.*nn).*cwn;
xs = xs + sin(paino.*nn).*cwn;
end
cwmt = sqrt(2.0).*cos(ic.*wmts);
xc = (2.0.*xc + cwmt).*ac0;
xs = 2.0.*xs.*as0;
ramp=sqrt(xc.^2+xs.^2);
rcos=xc./ramp;
rsin=xs./ramp;
if flat ==1
iout = sqrt(xc.^2+xs.^2).*idata(1:nsamp);
% output signal(ich)
qout = sqrt(xc.^2+xs.^2).*qdata(1:nsamp);
% output signal(qch)
else
iout = xc.*idata(1:nsamp) - xs.*qdata(1:nsamp);
% output signal(ich)
qout = xs.*idata(1:nsamp) + xc.*qdata(1:nsamp);
% output signal(qch)
end
else
iout=idata;
qout=qdata;
end

是否能将上面的MATLAB语言转化为VC++的语言,或者谁会瑞丽衰减或者多普勒频移的VC++仿真,先谢谢了。
不想用MATCOM转换,直接手工编写转换。

mcc 命令
help mcc
MCC Invoke MATLAB to C/C++ Compiler (Version 4.7).
MCC [-options] fun [fun2 ...]

Prepare fun.m for deployment outside of the MATLAB environment.
Generate wrapper files in C or C++ and optionally build standalone
binary files.

Write any resulting files into the current directory, by default.

For all targets except standalone, if more than one M-file is
specified, a C or C++ interface is generated for each M-file.
The only exception to this rule is when the file is specified
with a '-a' flag.

If C or object files are specified, they are passed to MBUILD along
with any generated C files.

If conflicting options are presented to MCC, the rightmost conflicting
option is used.

OPTIONS:

a <filename> Add <filename> to the CTF archive. If the specified file
is an M, mex or p file, this function will not be exported in the
resulting target.

b Generate an MS Excel compatible formula function for the
given list of M-files (requires MATLAB Builder EX).

B <filename>[:<arg>[,<arg>]] Specify bundle file. <filename> is a text
file containing Compiler command line options. The Compiler behaves
as if the "-B <filename>" were replaced by the contents of the
bundle file. Newlines appearing in these files are allowed and are
treated as whitespace. The MathWorks provides options files for the
following:

ccom Used for building COM objects on Windows (requires
MATLAB Builder NE)

cexcel Used for building Excel components (requires
MATLAB Builder EX installed)

cppcom Same as ccom. This option will be obsoleted
in a future release of MATLAB Builder NE.

cppexcel Same as cexcel. This option will be obsoleted
in a future release of MATLAB Builder EX.

cppsglcom Same as ccom. This option will be obsoleted
in a future release of MATLAB Builder NE.

cppsglexcel Same as cexcel. This option will be obsoleted
in a future release of MATLAB Builder EX.

csglcom Same as ccom. This option will be obsoleted
in a future release of MATLAB Builder NE.

csglexcel Same as cexcel. This option will be obsoleted
in a future release of MATLAB Builder EX.

cpplib Used for building a C++ shared library.

csharedlib Used for building a C shared library.

csglsharedlib
Same as csharedlib. This option will be
obsoleted in a future release of the MATLAB
Compiler.

dotnet Used for building .NET components on Windows
(requires MATLAB Builder NE installed)

pcode This option has been obsoleted since MATLAB
Compiler 4.0 (R14).

sgl Same as macro option m. This option will be
obsoleted in a future release of MATLAB Compiler.

sglcpp Same as macro option m. This option will be
obsoleted in a future release of MATLAB Compiler.

C For stand-alone applications and shared libraries, generate a separate
CTF archive. If this option is not specified, the CTF will be embedded
within the stand-alone application or library.

c C only. Generate C wrapper code. This is equivalent to "-T codegen"
as the rightmost argument on the command line.

d <directory> Output directory. All generated files will be put in
<directory>.

e Macro that generates a C Windows application on the Windows platform. On
non-Windows platforms, it is the same as the macro -m. This is
equivalent to the options "-W WinMain -T link:exe", which can be found
in the file <MATLAB>/toolbox/compiler/bundles/macro_option_e.

f <filename> Override the default options file with the specified
options file when calling MBUILD. This allows you to use different
ANSI compilers. This option is a direct pass-through to the MBUILD
script. See "External Interfaces" documentation for more
information.

F <project file> Specify that mcc use settings contained in a project file
(.prj). Project files created using either mcc or deploytool are eligible
to use this option. When using -F, no other arguments may be invoked
against mcc.

g Debug. Include debugging symbol information.

G Debug only. Simply turn debugging on, so debugging symbol
information is included.

I <path> Include path. Add <path> to the list of paths to search for
M-files. The MATLAB path is automatically included when running
from MATLAB. When running from DOS or the UNIX shell, the
MATLAB Compiler includes the paths from pathdef.m in
<matlabroot>/toolbox/local.

l Create function library. This option is equivalent to -W lib
-T link:lib. It generates library wrapper functions for each M-file
on the command line and calls your C compiler to build a shared
library, which exports these functions. The library name is the
component name, which is either derived from the name of the first
M-file on the command line or specified with the -n option.

m Macro that generates a C stand-alone application. This is
equivalent to the options "-W main -T link:exe", which can be found
in the file <MATLAB>/toolbox/compiler/bundles/macro_option_m.

M "<string>" Pass <string> to the MBUILD script to build an
executable. If -M is used multiple times, the rightmost occurrence
is used.

N Clear path. Clear the compilation search path of all directories
except the following core directories:
<matlabroot>/toolbox/matlab
<matlabroot>/toolbox/local
<matlabroot>/toolbox/compiler
It also retains all subdirectories of the above list that appear on
the MATLAB path at compile time.

o <outputfilename> Output name. Set the name of the final component and
CTF archive to <outputfilename>. A suitable, possibly
platform-dependent, extension is added to <outputfilename> (e.g.,
".exe" for Windows stand-alone applications). The default output
filename is the name of the first M-file (for stand-alone target)
or the name specified with the -W option. See option W for more
information.

p <directory> Add <directory> to the compilation search path. This
option can only be used in conjunction with the -N option. This
option will add <directory> to the compilation search path in the
same order as in your MATLAB path. If directory is not an absolute
path, it is assumed to be under the current working directory. The
rules for how these directories are included are
* If <directory> is on the original MATLAB path, the <directory>
and all its subdirectories that appear on the original path are
added to the compilation search path in the same order as it
appears on MATLAB path.
* If <directory> is not on the original MATLAB path, it is not
included in the compilation. (You can use -I to add it.)
If the same directory is added with both the -I and -p option (-N
appearing before both the options), the directory will be added as
per the rules of -p.

R <option> Specify the run-time options for the MATLAB Common Runtime
(MCR) usage:
mcc -m -R -nojvm,<args>,-nojit,<args> -v foo.m
mcc -m -R -nojvm,<args> -v -R -nojit,<args> foo.m
mcc -m -R -nojvm -R -nojit foo.m
mcc -m -R -nojvm -v foo.m
mcc -e -R -logfile,"bar.txt" -v foo.m

S Create Singleton MCR
Create a singleton MCR when compiling a COM object. Each
instance of the component uses the same MCR (requires MATLAB
Builder NE).

T <option> Specify target phase and type. The following table shows
valid <option> strings and their effects:

codegen - Generate a C/C++ wrapper file.
(This is the default -T setting.)
compile:exe - Same as codegen, plus compile C/C++ files to
object form suitable for linking into a
stand-alone executable.
compile:lib - Same as codegen, plus compile C/C++ files to
object form suitable for linking into a shared
library/DLL.
link:exe - Same as compile:exe, plus link object files
into a stand-alone executable.
link:lib - Same as compile:lib, plus link object files
into a shared library/DLL.

v Verbose. Show compilation steps.

w list. List the warning strings that could be thrown by the MATLAB
Compiler during compilation. These <msgs> can be used with another
form of the w option to enable or disable the warnings or to throw
them as error messages.

w <option>[:<msg>] Warnings. The possible options are "enable",
"disable", and "error". If "enable:<msg>" or "disable:<msg>" is
specified, enable or disable the warning associated with <msg>. If
"error:<msg>" is specified, enable the warning associated with
<msg> and treat any instances of that warning as an error. If the
<option> but not ":<msg>" is specified, the Compiler applies the
action to all warning messages. For backward compatibility with
previous Compiler revisions, "-w" (with no option) is the same as
"-w enable".

W <option> Wrapper functions. Specify which type of wrapper file
should be generated by the Compiler. <option> can be one of
"main", "WinMain", "lib:<string>", "cpplib:<string>",
"com:<component-name>,<class-name>,<version>", or "none"
(default). For the lib wrapper, <string> contains the name of the
shared library to build.

Y <license.dat file> Override the default license.dat file with the
specified argument.

? Help. Display this help message.

EXAMPLES:

Make a stand-alone C executable for myfun.m:
mcc -m myfun

Make stand-alone C executable for myfun.m. Look for
myfun.m in the directory /files/source, and put the resulting C files
and executable in the directory /files/target:
mcc -m -I /files/source -d /files/target myfun

Make a stand-alone C executable from myfun1.m and myfun2.m
(using one mcc call):
mcc -m myfun1 myfun2

Make a C shared/dynamically linked library called "liba" from a0.m and
a1.m
mcc -W lib:liba -T link:lib a0 a1

Make a CPP shared/dynamically linked library called "liba" from a0.m
and a1.m
mcc -W cpplib:liba -T link:lib a0 a1

See also compiler/function, MCCSAVEPATH, REALONLY, realsqrt, reallog,
realpow, COMPILER_BUG_REPORT, mbuild.

Reference page in Help browser
doc compiler/mcc
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-05-04
% Program 2-5
% fade.m
%
% Generate Rayleigh fading
%
function [iout,qout,ramp,rcos,rsin]=fade(idata,qdata,...
nsamp,tstp,fd,no,counter,flat)
%********************** variables *********************
% idata : input Ich data
% qdata : input Qch data
% iout : output Ich data
% qout : output Qch data
% ramp : Amplitude contaminated by fading
% rcos : Cosine value contaminated by fading
% rsin : Cosine value contaminated by fading
% nsamp : Number of samples to be simulated
% tstp : Minimum time resolution
% fd : maximum doppler frequency
% no : number of waves in order to generate fading
% counter : fading counter
% flat : flat fading or not
% (1-flat (only amplitude is fluctuated),0-normal
% (phase and amplitude are fluctutated))
%******************************************************
if fd ~= 0.0
ac0 = sqrt(1.0 ./ (2.0.*(no + 1)));
% power normalized constant(ich)
as0 = sqrt(1.0 ./ (2.0.*no));
% power normalized constant(qch)
ic0 = counter;
% fading counter
pai = 3.14159265;
wm = 2.0.*pai.*fd;
n = 4.*no + 2;
ts = tstp;
wmts = wm.*ts;
paino = pai./no;
xc=zeros(1,nsamp);
xs=zeros(1,nsamp);
ic=[1:nsamp]+ic0;
for nn=1:no
cwn = cos( cos(2.0.*pai.*nn./n).*ic.*wmts );
xc = xc + cos(paino.*nn).*cwn;
xs = xs + sin(paino.*nn).*cwn;
end
cwmt = sqrt(2.0).*cos(ic.*wmts);
xc = (2.0.*xc + cwmt).*ac0;
xs = 2.0.*xs.*as0;
ramp=sqrt(xc.^2+xs.^2);
rcos=xc./ramp;
rsin=xs./ramp;
if flat ==1
iout = sqrt(xc.^2+xs.^2).*idata(1:nsamp);
% output signal(ich)
qout = sqrt(xc.^2+xs.^2).*qdata(1:nsamp);
% output signal(qch)
else
iout = xc.*idata(1:nsamp) - xs.*qdata(1:nsamp);
% output signal(ich)
qout = xs.*idata(1:nsamp) + xc.*qdata(1:nsamp);
% output signal(qch)
end
else
iout=idata;
qout=qdata;
end

是否能将上面的MATLAB语言转化为VC++的语言,或者谁会瑞丽衰减或者多普勒频移的VC++仿真,先谢谢了。
不想用MATCOM转换,直接手工编写转换。
第2个回答  2009-04-28
高手啊!

MATLAB语言转化为VC++语言
是否能将上面的MATLAB语言转化为VC++的语言,或者谁会瑞丽衰减或者多普勒频移的VC++仿真,先谢谢了。 不想用MATCOM转换,直接手工编写转换。 已赞过 已踩过< 你对这个回答的评价是? 评论 收起 51cjh 2009-04-28 · TA获得超过725个赞 知道小有建树答主 回答量:953 采纳率:0% 帮助的人:339万 我...

vc++ matlab混合编程 fsolve
这个可以有四种方法实现:(1)将Matlab程序编译成 C\/C++源文件并嵌入VC++;(2)在C/C++程序中利用 Matlab engine调用 Matlab函数;(3)在C\/C++程序中直接使用 Matlab C\/C++ Math Library;(4)将.m文件编译成 *.dll文件嵌入到 VC++的程序中。自己上网查一下。不过告诉你一个简单的,在matlab...

VC++与Matlab的优劣比较
matlab是一种分析工具,他提供了很多工具箱,能做很多专业的分析处理,因此在应用过程上来说,matlab很容易对工程分析建立数学模型,得到仿真结果,能够快速进行工程分析。因为matlab基本上基于pc应用,所以得到正确的处理过程后,可以用其他的语言实现这个过程,应用到特殊的场合。因此,matlab是专业性的应用软...

如何脱离MATLAB工作环境,实现MATLAB与Visual Basic语言的混合编程...
注释掉,或者干脆删掉,否则,在客户机中运行MATLAB与Visual Basic语言混合编成的程序时,会出现:“Undefined command\/function 'set_param'”的错误。2、在Matlab7 的命令窗口运行下列命令:rehash toolboxcache 完成工具箱加载和更新。3、安装vc++6.0软件,为Matlab编译器的安装和配置做准备;4、在Matl...

MATLAB是用什么语言写的
MATLAB的历史可以追溯到早期,它的起源与FORTRAN语言有关。自1984年第一版问世以来,MATLAB的核心结构经历了显著变化。最初的版本主要依赖FORTRAN,但随着技术的发展,从MATLAB第1版开始,其核心部分转而使用了C语言进行编写。至于界面部分,据推测,它可能是基于VC++这样的工具构建的。尽管MATLAB并非以速度...

matlab和VC++哪个更适合开发新软件,哪个开发起来方便简单快速?
这两个没可比性 matlab主要用于矩阵相关的运算,比如图像处理 VC++是一个编程语言,可以用来开发新软件,当然,matlab也提供了vc++的编程接口,可以被VC++调用 java主要用于网络编程,实时性不如vc++,底层编程一般用VC++

怎么把matlab程序打包成独立的可执行文件
Mbuild –setup 然后根据提示执行相应的操作,使用者可根据自己计算机中现有编译器的情况选择合适的编译器,如VC++ 6.0、VC++7.0、Bland C的编译器等,目前Matlab好象还不支持VC++8.0(我计算机安装的就是VC++2005,Matlab就无法识别)。当然,如果你的计算机里根本就没有安装其他任何语言的编译器,也...

同样功能的程序,matlab 为什么比VC++6.0 运行慢很多
开发的层次不一样。VC更接近于系统低层,甚至可以直接访问硬件,效率很高。编译后的代码能独立运行。而matlab则是封装了许多功能的一个应用软件,其开发的程序必须在这个系统的支持下才能运行,效率低是肯定的。甚至matlab这个软件也是用C语言编写的。

Matlab里用的是什么语言
以Matlab为例,其开发过程涉及多种编程语言和技术。大多数核心代码是用VC++编写的,因此在安装包中可以找到vcredist_x86,这表明了VC++的运行时库的存在。除了VC++,Matlab还广泛使用了其他编程语言和技术,如Perl和Python,这些语言在特定功能或组件中发挥着重要作用。此外,Java也是其开发过程中不可或缺...

vc++和matlab比较,在工程应用中有什么不同?
matlab做研究,写算法,节省时间,做产品还是用VC,运行速度快,不要求客户装matlab

相似回答
大家正在搜