所以我有一个3x8x8逻辑,包括0和1(1表示显着结果,0表示非显着结果)。当我拿第一个时,它看起来像这样(iteration_signf_EMG_EMG(:,:,1)):
1 0 1 0 0 0 0 0
1 0 1 0 1 0 0 1
1 1 1 1 1 0 1 0
我想用imagesc绘制这个,所以所有的1都是红色的,所有的0都是蓝色的,但这个数字奇怪地移动了,我似乎无法修复它......
以下是我使用的代码:
imagesc(iteration_signf_EMG_EMG(:,:,1));
set(gca, 'xtick', xbounds(1):1:xbounds(2));
set(gca, 'ytick', ybounds(1):1:ybounds(2));
colorbar
grid on
这是输出数字: what it looks like 这是我想要的样子: what it should look like
我希望你们能帮助我!
干杯
答案 0 :(得分:0)
图片在图形上是相同的,您只应将轴更改为您想要的间隔,下面的代码将根据您的需要更改轴。 将其添加到您的脚本中并查看更改。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<WinSock2.h>
#include<conio.h>
#pragma comment(lib, "ws2_32.lib")
#define BUFFERSZ 1024
#define PORT 19010
typedef enum
{
BLOCKING = 0,
NONBLOCKING = 1
} BLOCKING_MODE;
int main(void)
{
struct sockaddr_in UserApp;
struct sockaddr_in Server;
int ServerLen = sizeof(Server);
int ReceivedDataLen;
UINT8 ReceiveBuffer[BUFFERSZ];
WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
SOCKET ListenSocket;
UINT32 Mode = (UINT32)NONBLOCKING;
UINT32 bufferdata;
int loop;
if (WSAStartup(wVersionRequested, &wsaData) == 0)
{
/* Create UDP socket */
if ((ListenSocket = WSASocketW(AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, 0, WSA_FLAG_OVERLAPPED)) != INVALID_SOCKET)
{
int SocketOption = 1;
setsockopt(ListenSocket, SOL_SOCKET, SO_REUSEADDR, (char*)&SocketOption, sizeof(SocketOption));
UserApp.sin_family = AF_INET;
UserApp.sin_port = htons(PORT);
UserApp.sin_addr.s_addr = htonl(INADDR_ANY);
// Bind socket
if (bind(ListenSocket, (PSOCKADDR)&UserApp, sizeof(UserApp)) != SOCKET_ERROR)
{
/* Using ioctlsocket() */
if (ioctlsocket(ListenSocket, FIONBIO, &Mode) != SOCKET_ERROR)
{
ioctlsocket(ListenSocket, FIONREAD, &bufferdata);
/* Read data from buffer */
if (bufferdata != 0)
{
ReceivedDataLen = recvfrom(ListenSocket, ReceiveBuffer, BUFFERSZ, 0, (struct sockaddr *)&Server, &ServerLen);
}
/* Display received data */
printf("\n%d :: \n", __LINE__);
for (loop = 0; loop < ReceivedDataLen; loop++)
{
printf("%02X ", ReceiveBuffer[loop]);
}
printf("\n");
}
/* Using select() */
FD_SET ReadSet;
FD_ZERO(&ReadSet);
FD_SET(ListenSocket, &ReadSet);
struct timeval TimeOut;
TimeOut.tv_usec = 100000; /* 0.1sec timeout */
bufferdata = 0;
bufferdata = select(0, &ReadSet, NULL, NULL, &TimeOut);
if (bufferdata != 0)
{
ReceivedDataLen = recvfrom(ListenSocket, ReceiveBuffer, BUFFERSZ, 0, (struct sockaddr *) &Server, &ServerLen);
}
/* Display received data */
printf("\n%d :: \n", __LINE__);
for (loop = 0; loop < ReceivedDataLen; loop++)
{
printf("%02X ", ReceiveBuffer[loop]);
}
printf("\n");
closesocket(ListenSocket);
}
}
}
WSACleanup();
_getch();
return 0;
}