我有Java代码将TCP / IP数据发送到Matlab,使用以下代码:
four=tcpip('localhost', 4444, 'NetworkRole', 'client');
set(four,'Timeout', 30);
set(four, 'InputBufferSize', 7688);
fopen(four);
fread(four,1,'double')
ans = 4.4
这一切都按预期工作。当我运行相同的Java代码发送到Simulink Instrument Control Toolbok连接到作用域的TCP / IP接收时,它似乎只在我有一个数据类型为单一时接收数据,但数据的值是2.275。
Block {
BlockType Reference
Name "Data From Java"
SID "1"
Ports [0, 1]
Position [120, 246, 230, 294]
ZOrder 2
LibraryVersion "1.84"
SourceBlock "instrumentlib/TCP//IP Receive"
SourceType "TCP/IP Receive"
Host "127.0.0.1"
Port "4444"
DataSize "[1 1]"
EnableBlockingMode on
Timeout "30"
SampleTime "0.01"
DataType "single"
ByteOrder "BigEndian"
}
如何在我的Simulink模型中读取二进制double(float)?