为了账号安全,请及时绑定邮箱和手机立即绑定

matlab中connect函数用法?

matlab中connect函数用法?

iOS
慕后森 2019-02-06 16:07:37
matlab中connect函数用法
查看完整描述

2 回答

?
泛舟湖上清波郎朗

TA贡献1818条经验 获得超3个赞

 connect()用于建立与指定socket的连接。
  头文件: #include <winsock.h>
  函数原型: int PASCAL FAR connect( SOCKET s, const struct sockaddr FAR* name, int namelen);
  参数:
  s:标识一个未连接socket
  name:指向要连接套接字的sockaddr结构体的指针
  namelen:sockaddr结构体的字节长度
  注释:

  本函数用于创建与指定外部端口的连接。s参数指定一个未连接的数据报或流类套接口。如套接口未被捆绑,则系统赋给本地关联一个唯一的值,且设置套接口为已捆绑。请注意若名字结构中的地址域为全零的话,则connect()将返回WSAEADDRNOTAVAIL错误。
  对于流类套接口(SOCK_STREAM类型),利用名字来与一个远程主机建立连接,一旦套接口调用成功返回,它就能收发数据了。对于数据报类套接口(SOCK_DGRAM类型),则设置成一个缺省的目的地址,并用它来进行后续的send()与recv()调用。
  返回值:

  若无错误发生,则connect()返回0。否则的话,返回SOCKET_ERROR错误,应用程序可通过WSAGetLastError()获取相应错误代码。对非阻塞套接口而言,若返回值为SOCKET_ERROR则应用程序调用WSAGetLsatError()。如果它指出错误代码为WSAEWOULDBLOCK,则您的应用程序可以:
  1.用select(),通过检查套接口是否可写,来确定连接请求是否完成。
  2.如果您的应用程序使用基于消息的WSAAsynSelect()来表示对连接事件的兴趣,则当连接操作完成后,您会收到一个FD_CONNECT消息。
  错误代码

  WSAENOTINITIALISED:在使用此API之前应首先成功地调用WSAStartup()。
  WSAENETDOWN:WINDOWS套接口实现检测到网络子系统失效。
  WSAEADDRINUSE:所指的地址已在使用中。
  WSAEINTR:通过一个WSACancelBlockingCall()来取消一个(阻塞的)调用。
  WSAEINPROGRESS:一个阻塞的WINDOWS套接口调用正在运行中。
  WSAEADDRNOTAVAIL:在本地机器上找不到所指的地址。
  WSAENOTSUPPORT:所指族中地址无法与本套接口一起使用。
  WSAECONNREFUSED:连接尝试被强制拒绝。
  WSAEDESTADDREQ:需要目的地址。
  WSAEFAULT:namelen参数不正确。
  WSAEINVAL:套接口没有准备好与一地址捆绑。
  WSAEISCONN:套接口早已连接。
  WSAEMFILE:无多余文件描述字。
  WSAENETUNREACH:当前无法从本主机访问网络。
  WSAENOBUFS:无可用缓冲区。套接口未被连接。
  WSAENOTSOCK:描述字不是一个套接口。
  WSAETIMEOUT:超时时间到。
  WSAEWOULDBLOCK:套接口设置为非阻塞方式且连接不能立即建立。可用select()调用对套接口写,因为select()时会进行连接。



查看完整回答
反对 回复 2019-03-19
?
子衿沉夜

TA贡献1828条经验 获得超3个赞

connect Block-diagram interconnections of dynamic systems.

connect computes an aggregate model for a block diagram interconnection
of dynamic systems. You can specify the block diagram connectivity in
two ways:

Name-based interconnection
In this approach, you name the input and output signals of all blocks
SYS1, SYS2,... in the block diagram, including the summation blocks.
The aggregate model SYS is then built by
SYS = connect(SYS1,SYS2,...,INPUTS,OUTPUTS)
where INPUTS and OUTPUTS are the names of the block diagram external
I/Os (specified as strings or string vectors).

Example 1: Given SISO models C and G, you can construct the closed-loop
transfer T from r to y using

e u
r --->O-->[ C ]---[ G ]-+---> y
- | |
+<----------------+

C.InputName = 'e'; C.OutputName = 'u';
G.InputName = 'u'; G.OutputName = 'y';
Sum = sumblk('e = r-y');
T = connect(G,C,Sum,'r','y')

Example 2: If C and G above are two-input, two-output models instead,
you can form the MIMO transfer T from r to y using
C.u = 'e'; C.y = 'u';
G.u = 'u'; G.y = 'y';
Sum = sumblk('e = r-y',2);
T = connect(G,C,Sum,'r','y')
Note that C.u,C.y is shorthand for C.InputName,C.OutputName and that
'r','y' select all entries of the two-entry vector signals r and y.

Example 3: If you already have specified I/O names for C and G, you
can build the closed-loop model T using:
Sum = sumblk('%e = r - %y',C.u,G.y);
T = connect(G,C,Sum,'r',G.y)
See SUMBLK for more details on using aliases like %e and %y.

Index-based interconnection
In this approach, first combine all system blocks into an aggregate,
unconnected model BLKSYS using APPEND. Then construct a matrix Q
where each row specifies one of the connections or summing junctions
in terms of the input vector U and output vector Y of BLKSYS. For
example, the row [3 2 0 0] indicates that Y(2) feeds into U(3), while
the row [7 2 -15 6] indicates that Y(2) - Y(15) + Y(6) feeds into U(7).
The aggregate model SYS is then obtained by
SYS = connect(BLKSYS,Q,INPUTS,OUTPUTS)
where INPUTS and OUTPUTS are index vectors into U and Y selecting the
block diagram external I/Os.

Example: You can construct the closed-loop model T for the block
diagram above as follows:
BLKSYS = append(C,G);
% U = inputs to C,G. Y = outputs of C,G
% Here Y(1) feeds into U(2) and -Y(2) feeds into U(1)
Q = [2 1; 1 -2];
% External I/Os: r drives U(1) and y is Y(2)
T = connect(BLKSYS,Q,1,2)

Note:
* connect always returns a state-space or FRD model SYS
* States that do not contribute to the I/O transfer from INPUTS to
OUTPUTS are automatically discarded. To prevent this, set the
"Simplify" option to FALSE:
OPT = connectOptions('Simplify',false);
SYS = connect(...,OPT)



查看完整回答
反对 回复 2019-03-19
  • 2 回答
  • 0 关注
  • 850 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信