您的位置:首页 > 编程语言 > MATLAB

Matlab产生独立可运行C代码

2014-02-19 12:14 274 查看
关于Matlab R2009a里,提到的比较多就是Real-time Workshop (虽然以前也有很多这方面的帮助)

最近跟Mathworks工程是will聊天,彻底询问了一下关于Matlab转换成独立可编译C代码的问题,得到的答复仍然是:

1:Simulink模型转换成real-time C代码已经很完美(包含比较新的Stateflow等)

2:Matlab的代码,如果是基本的代码的话,可以转换成独立运行的C代码,但是很多工具箱还不支持。

如果需要把比如说image processing, neural network等,需要用Matlab提供的基本函数改写这些代码(似乎很麻烦,所以尽量开发的时候使用Simulink)。

现在大家关心的问题是,那些函数可以直接转化成C代码,以下是函数列表:

大家可以看到,除了基本函数意外,对信号处理的函数支持的特别全面。

这也很明显,因为很多都是embedded system,信号处理是最常用的功能。

一般的算法,可以通过基本语句完成。

Aerospace Blockset

Arithmetic operators

Casting

Complex numbers

Derivative and integral

Discrete math

Exponential

Filtering and convolution

Fixed-Point Toolbox

HDL code generation

Histogram

Input and output

Interpolation and computational geometry

Logical operators

Matrices and arrays

Polynomials

Relational operators

Rounding and remainder

Set

Signal processing

Special values

Specialized math

Statistics

String

Structure

Trigonometry

具体支持的Maltab函数列表

Function

Product

Remarks/Limitations

abs

MATLAB



abs

Fixed-Point Toolbox



acos

MATLAB

Generates an error during simulation and returns NaN for Real-Time Workshop targets when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

acosd

MATLAB



acosh

MATLAB

Generates an error during simulation and returns NaN for Real-Time Workshop targets when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

acot

MATLAB



acotd

MATLAB



acoth

MATLAB



acsc

MATLAB



acscd

MATLAB



acsch

MATLAB



add

Fixed-Point Toolbox



all

MATLAB



all

Fixed-Point Toolbox



and

MATLAB



angle

MATLAB



any

MATLAB



any

Fixed-Point Toolbox



asec

MATLAB



asecd

MATLAB



asech

MATLAB



asin

MATLAB

Generates an error during simulation and returns NaN for Real-Time Workshop targets when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

asind

MATLAB



asinh

MATLAB



assert

MATLAB

Generates specified error messages at compile time only if all input arguments are constants or depend on constants. Otherwise, generates specified error messages at runtime.

atan

MATLAB



atan2

MATLAB



atand

MATLAB



atanh

MATLAB

Generates an error during simulation and returns NaN for Real-Time Workshop targets when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

beta

MATLAB



betainc

MATLAB



betaln

MATLAB



bin2dec

MATLAB



bitand MATLAB

Does not support floating-point inputs. The arguments must belong to an integer class.

bitand Fixed-Point Toolbox

Not supported for slope-bias scaled fi objects.

bitandreduce Fixed-Point Toolbox



bitcmp MATLAB

Does not support floating-point input for the first argument. The first argument must belong to an integer class.

bitcmp Fixed-Point Toolbox



bitconcat Fixed-Point Toolbox



bitget MATLAB



bitget Fixed-Point Toolbox



bitor MATLAB

Does not support floating-point inputs. The arguments must belong to an integer class.

bitor Fixed-Point Toolbox

Not supported for slope-bias scaled fi objects.

bitorreduce Fixed-Point Toolbox



bitreplicate Fixed-Point Toolbox



bitrevorder Signal Processing Toolbox

Requires Signal Processing Blockset™ license.

bitrol Fixed-Point Toolbox



bitror Fixed-Point Toolbox



bitset MATLAB

Does not support floating-point input for the first argument. The first argument must belong to an integer class.

bitset Fixed-Point Toolbox



bitshift MATLAB

Does not support floating-point input for the first argument. The first argument must belong to an integer class.

bitshift Fixed-Point Toolbox



bitsliceget Fixed-Point Toolbox



bitsll Fixed-Point Toolbox

bitsra Fixed-Point Toolbox



bitsrl Fixed-Point Toolbox



bitxor MATLAB

Does not support floating-point inputs. The arguments must belong to an integer class.

bitxor Fixed-Point Toolbox

Not supported for slope-bias scaled fi objects.

bitxorreduce Fixed-Point Toolbox



bsxfun MATLAB —

cart2pol

MATLAB



cart2sph

MATLAB



cast

MATLAB



cat

MATLAB



ceil

MATLAB



ceil Fixed-Point Toolbox



char

MATLAB



chol

MATLAB

Does not allow two output arguments.

circshift

MATLAB



class

MATLAB



compan

MATLAB



complex

MATLAB



complex

Fixed-Point Toolbox



cond MATLAB —

conj

MATLAB



conj

Fixed-Point Toolbox



conv

MATLAB



conv2

MATLAB



convergent

Fixed-Point Toolbox



cos

MATLAB



cosd

MATLAB



cosh

MATLAB



cot

MATLAB



cotd

MATLAB



coth

MATLAB



cov

MATLAB



cross

MATLAB

If supplied, dim must be a constant.

csc

MATLAB



cscd

MATLAB



csch

MATLAB



ctranspose

MATLAB



ctranspose

Fixed-Point Toolbox



cumprod

MATLAB



cumsum

MATLAB



cumtrapz

MATLAB



deconv

MATLAB



det

MATLAB



detrend

MATLAB

If supplied and not empty, the input argument bp must satisfy the following requirements:

Be real

Be sorted in ascending order

Restrict elements to integers in the interval [1, n-2], where n is the number of elements in a column of input argument X , or the number of elements in X when X is a row vector

Contain all unique values

diag

MATLAB

If supplied, the argument representing the order of the diagonal matrix must be a real and scalar integer value.

diag

Fixed-Point Toolbox

If supplied, the index, k, must be a real and scalar integer value that is not a fi object.

diff

MATLAB

If supplied, the arguments representing the number of times to apply diff and the dimension along which to calculate the difference must be constants.

disp

Fixed-Point Toolbox



divide

Fixed-Point Toolbox

Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

Complex and imaginary divisors are not supported.

dot

MATLAB



double

MATLAB



double

Fixed-Point Toolbox



eig

MATLAB

QZ algorithm used in all cases. Consequently, for the standard eigenvalue problem (B identity), results will be similar to those obtained using the following code in MATLAB:

[V,D] = eig(A,eye(size(A)),'qz')However, V may represent a different basis of eigenvectors, and the eigenvalues in D may not be in the same order.

Options 'balance', 'nobalance', and 'chol' are not supported.

Outputs are always of complex type.

ellipke

MATLAB



end

Fixed-Point Toolbox



eps

MATLAB



eps

Fixed-Point Toolbox

Supported for scalar fixed-point signals only.

Supported for scalar, vector, and matrix, fi single and fi double signals.

eq

MATLAB



eq

Fixed-Point Toolbox

Not supported for fixed-point signals with different biases.

erf

MATLAB



erfc

MATLAB



erfcinv

MATLAB



erfcx

MATLAB



erfinv

MATLAB



exp

MATLAB



expint

MATLAB



expm

MATLAB



expm1

MATLAB



eye

MATLAB

Dimensions must be real, nonnegative, integer constants.

factorial

MATLAB



false

MATLAB

Dimensions must be real, nonnegative, integer constants.

fft

MATLAB

Length of input vector must be a power of 2.

fft2

MATLAB

Length of input matrix dimensions must each be a power of 2.

fftshift MATLAB



fi

Fixed-Point Toolbox

Use to create a fixed-point constant or variable.

The default constructor syntax without any input arguments is not supported.

The syntax fi('PropertyName',PropertyValue...) is not supported. To use property name/property value pairs, you must first specify the value v of the fi object as in fi(v,'PropertyName',PropertyValue...).

Works for all input values when complete numerictype information of the fi object is provided.

Works only for constant input values (value of input must be known at compile time) when complete numerictype information of the fi object is not specified.

numerictype object information must be available for non-fixed-point Simulink inputs.

filter

MATLAB



filter2

MATLAB



fimath

Fixed-Point Toolbox

Fixed-point signals coming in to an Embedded MATLAB Function block from Simulink are assigned the fimath object defined in the Embedded MATLAB Function dialog in the Model Explorer.

Use to create fimath objects in Embedded MATLAB code.

fix

MATLAB



fix

Fixed-Point Toolbox



fft2

MATLAB

Dimensions 1 and 2 of the input matrix must have power of two length

flipdim

MATLAB



fliplr

MATLAB



flipud

MATLAB



floor

MATLAB



floor

Fixed-Point Toolbox



freqspace

MATLAB



gamma

MATLAB



gammainc

MATLAB



gammaln

MATLAB



gcd

MATLAB



ge

MATLAB



ge

Fixed-Point Toolbox

Not supported for fixed-point signals with different biases.

get

Fixed-Point Toolbox

The syntax structure = get(o) is not supported.

getlsb

Fixed-Point Toolbox



getmsb

Fixed-Point Toolbox



gt

MATLAB



gt

Fixed-Point Toolbox

Not supported for fixed-point signals with different biases.

hex2dec

MATLAB



hilb

MATLAB



hist

MATLAB

Histogram bar plotting not supported; call with at least one output argument.

If supplied, the second argument x must be a scalar constant.

Inputs must be real.

histc

MATLAB



horzcat

Fixed-Point Toolbox



hypot

MATLAB



idivide

MATLAB

opt string must be in lowercase.

For efficient generated code, MATLAB rules for divide by zero are supported only for the 'round' option.

ifft

MATLAB

Length of input vector must be a power of 2.

Output of ifft block is always complex.

Does not support the 'symmetric' option.

ifft2

MATLAB

Length of input matrix dimensions must each be a power of 2.

Does not support the 'symmetric' option.

ifftshift

MATLAB



imag

MATLAB



imag

Fixed-Point Toolbox



ind2sub

MATLAB

The first argument should be a valid size vector. Size vectors for arrays with more than intmax elements are not supported.

inf

MATLAB

Dimensions must be real, nonnegative, integer constants.

int8, int16, int32

MATLAB



int, int8, int16, int32

Fixed-Point Toolbox



interp1

MATLAB

Supports only linear and nearest interpolation methods.

Does not handle evenly spaced X indices separately.

X must be strictly monotonically increasing or strictly monotonically decreasing; does not reorder indices.

interp1q, see interp1

MATLAB

X must be strictly monotonically increasing or strictly monotonically decreasing; does not reorder indices.

intmax

MATLAB —

intmin

MATLAB



inv

MATLAB

Singular matrix inputs can produce nonfinite values that differ from MATLAB results.

invhilb

MATLAB



ipermute

MATLAB



isa

MATLAB



ischar

MATLAB



iscolumn

Fixed-Point Toolbox



isempty

MATLAB



isempty

Fixed-Point Toolbox



isequal

MATLAB



isequalwithequalnans

MATLAB



isfi

Fixed-Point Toolbox



isfimath

Fixed-Point Toolbox



isfinite

MATLAB



isfinite

Fixed-Point Toolbox



isfloat

MATLAB



isinf

MATLAB



isinf

Fixed-Point Toolbox



isinteger

MATLAB



islogical

MATLAB



isnan

MATLAB



isnan

Fixed-Point Toolbox



isnumeric

MATLAB



isnumeric

Fixed-Point Toolbox



isnumerictype

Fixed-Point Toolbox



isreal

MATLAB



isreal

Fixed-Point Toolbox



isrow

Fixed-Point Toolbox



isscalar

MATLAB



isscalar

Fixed-Point Toolbox



issigned

Fixed-Point Toolbox



issorted

MATLAB



isstruct

MATLAB



isvector

MATLAB



isvector

Fixed-Point Toolbox



kron

MATLAB



lcm

MATLAB



ldivide

MATLAB



le

MATLAB



le

Fixed-Point Toolbox

Not supported for fixed-point signals with different biases.

length

MATLAB



length

Fixed-Point Toolbox



linspace

MATLAB

Number of points N must be a constant that is positive, real, and integer valued

log

MATLAB

Generates an error during simulation and returns NaN for Real-Time Workshop targets when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

log2

MATLAB



log10

MATLAB



log1p

MATLAB



logical

MATLAB



logical

Fixed-Point Toolbox



logspace

MATLAB



lowerbound

Fixed-Point Toolbox



lsb

Fixed-Point Toolbox

Supported for scalar fixed-point signals only.

Supported for scalar, vector, and matrix, fi single and double signals.

lt

MATLAB



lt

Fixed-Point Toolbox

Not supported for fixed-point signals with different biases.

lu

MATLAB



magic

MATLAB



max

MATLAB



max

Fixed-Point Toolbox



mean

MATLAB



median

MATLAB



meshgrid

MATLAB



min

MATLAB



min

Fixed-Point Toolbox



minus

MATLAB



minus

Fixed-Point Toolbox

Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

mldivide

MATLAB



mod

MATLAB



mode

MATLAB

Does not support third output argument C (cell array)

mpower

MATLAB



mpy

Fixed-Point Toolbox



mrdivide

MATLAB



mrdivide

Fixed-Point Toolbox



mtimes

MATLAB



mtimes

Fixed-Point Toolbox

Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

NaN or nan

MATLAB

Dimensions must be real, nonnegative, integer constants

nargin

MATLAB



nargout

MATLAB



nchoosek

MATLAB



nchoosek

MATLAB



nchoosek

MATLAB



nchoosek

MATLAB



ndgrid

MATLAB



ndims

MATLAB



ndims

Fixed-Point Toolbox



ne

MATLAB



ne

Fixed-Point Toolbox

Not supported for fixed-point signals with different biases.

nearest

Fixed-Point Toolbox



nextpow2

MATLAB



norm MATLAB



normest MATLAB



not

MATLAB



nthroot

MATLAB



numberofelements

Fixed-Point Toolbox

Returns the number of elements of fi objects in the Embedded MATLAB subset (works the same as numel for fi objects in Embedded MATLAB).

numel

MATLAB

Returns the number of elements of fi objects in the Embedded MATLAB subset, rather than always returning 1.

numerictype

Fixed-Point Toolbox

Fixed-point signals coming in to an Embedded MATLAB Function block from Simulink are assigned a numerictype object that is populated with the signal's data type and scaling information.

Returns the data type when the input is a non-fixed-point signal.

Use to create numerictype objects in Embedded MATLAB code.

ones

MATLAB

Dimensions must be real, nonnegative, integer constants

or

MATLAB



pascal

MATLAB



permute

MATLAB



permute

Fixed-Point Toolbox



pi

MATLAB



pinv

MATLAB



planerot

MATLAB



plus

MATLAB



plus

Fixed-Point Toolbox

Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

pol2cart

MATLAB



poly

MATLAB

Does not discard nonfinite input values

Complex input always produces complex output

polyfit

MATLAB



polyval

MATLAB



pow2

Fixed-Point Toolbox



power

MATLAB

Generates an error during simulation and returns NaN for Real-Time Workshop targets when both X and Y are real, but power(X,Y) is complex. To get the complex result, make the input value X complex by passing in complex(X). For example, power(complex(X),Y).

Generates an error during simulation and returns NaN for Real-Time Workshop targets when both X and Y are real, but X .^ Y is complex. To get the complex result, make the input value X complex by using complex(X). For example, complex(X).^Y.

prod

MATLAB



qr

MATLAB



quatconj

Aerospace Blockset™



quatdivide

Aerospace Blockset



quatinv

Aerospace Blockset



quatmod

Aerospace Blockset



quatmultiply

Aerospace Blockset



quatnorm

Aerospace Blockset



quatnormalize

Aerospace Blockset



rand

MATLAB

Does not support the V5 generator.

May not match MATLAB results if seeded with negative values.

randn

MATLAB

May not match MATLAB results if seeded with negative values

range

Fixed-Point Toolbox



rank

MATLAB



rcond

MATLAB



rdivide

MATLAB



rdivide

Fixed-Point Toolbox



real

MATLAB



real

Fixed-Point Toolbox



reallog

MATLAB



realmax

MATLAB



realmax

Fixed-Point Toolbox



realmin

MATLAB



realmin

Fixed-Point Toolbox



realpow

MATLAB



realsqrt

MATLAB



reinterpretcast

Fixed-Point Toolbox



rem

MATLAB



repmat

MATLAB



repmat

Fixed-Point Toolbox



rescale

Fixed-Point Toolbox



reshape

MATLAB



reshape

Fixed-Point Toolbox



rot90

MATLAB



round

MATLAB



round

Fixed-Point Toolbox



sec

MATLAB



secd

MATLAB



sech

MATLAB



shiftdim

MATLAB

Second argument must be a constant

Class of second argument must be single or double

sign

MATLAB



sign

Fixed-Point Toolbox



sin

MATLAB



sind

MATLAB



single

MATLAB



single

Fixed-Point Toolbox



sinh

MATLAB



size

MATLAB



size

Fixed-Point Toolbox



sort

MATLAB



sort

Fixed-Point Toolbox



sortrows

MATLAB



sosfilt

Signal Processing Toolbox

Requires Signal Processing Blockset license

sph2cart

MATLAB



squeeze

MATLAB



sqrt

MATLAB

Generates an error during simulation and returns NaN for Real-Time Workshop targets when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

sqrt

Fixed-Point Toolbox

Complex and [Slope Bias] inputs error out.

Negative inputs yield a 0 result.

std

MATLAB



strcmp

MATLAB

Arguments must be computable at compile time.

struct MATLAB



sub

Fixed-Point Toolbox



sub2ind

MATLAB

The first argument should be a valid size vector. Size vectors for arrays with more than intmax elements are not supported.

subsasgn

Fixed-Point Toolbox



subspace

MATLAB



subsref

Fixed-Point Toolbox



sum

MATLAB



sum

Fixed-Point Toolbox



svd

MATLAB



tan

MATLAB



tand

MATLAB



tanh

MATLAB



times

MATLAB



times

Fixed-Point Toolbox

Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

toeplitz

MATLAB



trace

MATLAB



trapz

MATLAB



transpose

MATLAB



transpose

Fixed-Point Toolbox



tril

MATLAB

If supplied, the argument representing the order of the diagonal matrix must be a real and scalar integer value.

tril

Fixed-Point Toolbox

If supplied, the index, k, must be a real and scalar integer value that is not a fi object.

triu

MATLAB

If supplied, the argument representing the order of the diagonal matrix must be a real and scalar integer value.

triu

Fixed-Point Toolbox

If supplied, the index, k, must be a real and scalar integer value that is not a fi object.

true

MATLAB

Dimensions must be real, nonnegative, integer constants

typecast

MATLAB

Value of string input argument type must be lower case

You may receive a size error when you use typecast with inheritance of input port data types in Embedded MATLAB Function blocks. To avoid this error, specify the block's input port data types explicitly.

uint8, uint16, uint32

MATLAB



uint8, uint16, uint32

Fixed-Point Toolbox



uminus

MATLAB



uminus

Fixed-Point Toolbox



uplus

MATLAB



uplus

Fixed-Point Toolbox



upperbound

Fixed-Point Toolbox



vander

MATLAB



var

MATLAB



vertcat

Fixed-Point Toolbox



wilkinson

MATLAB



xcorr

Signal Processing Toolbox

Does not support the case where A is a matrix

Does not support partial (abbreviated) strings of biased, unbiased, coeff, or none

Requires Signal Processing Blockset license

xor

MATLAB



zeros

MATLAB

Dimensions must be real, nonnegative, integer constants
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: