小编iju*_*ath的帖子

在 matplotlib 中用矩形插值绘制一条线

我想绘制数据,其中连续的点由矩形的部分连接,或者是平坦的然后垂直的,或者垂直的然后平坦的。这是一个天真的方法:

import matplotlib.pyplot as plt

x_data = [0.0, 1.0, 3.0, 4.5, 7.0]
y_data = [1.5, 3.5, 6.0, 2.0, 9.0]

# Linear interpolation
plt.plot(x_data, y_data, label='linear_interp')

# Vertical first interpolation
x_data_vert_first = [0.0, 0.0, 1.0, 1.0, 3.0, 3.0, 4.5, 4.5, 7.0]
y_data_vert_first = [1.5, 3.5, 3.5, 6.0, 6.0, 2.0, 2.0, 9.0, 9.0]
plt.plot(x_data_vert_first, y_data_vert_first, label="vert_first")

# Horizontal first interpolation
x_data_flat_first = [0.0, 1.0, 1.0, 3.0, 3.0, 4.5, 4.5, 7.0, 7.0]
y_data_flat_first = [1.5, 1.5, 3.5, 3.5, 6.0, 6.0, 2.0, 2.0, 9.0] …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

3
推荐指数
1
解决办法
2879
查看次数

当a是数字时,while(!a)是什么意思?

试图破译这段C代码:

int WaitForPacket(uint16 milliseconds, Dexcom_packet* pkt, uint8 channel) {
uint32 start = getMs();
uint8 * packet = 0;
uint32 i = 0;
uint32 seven_minutes = 420000;
int nRet = 0;
swap_channel(nChannels[channel], fOffset[channel]);

while (!milliseconds || (getMs() - start) < milliseconds) {
    i++;
    if(!(i % 60000)) {
        strobe_radio(channel);
    }
    doServices();
    if((getMs() - start) > seven_minutes) {
        killWithWatchdog();
        delayMs(2000);
    }
    blink_yellow_led();
    if (packet = radioQueueRxCurrentPacket()) {
        uint8 len = packet[0];
        fOffset[channel] += FREQEST;
        memcpy(pkt, packet, min8(len+2, sizeof(Dexcom_packet)));
        if(radioCrcPassed()) {
            if(pkt->src_addr == dex_tx_id …
Run Code Online (Sandbox Code Playgroud)

c conditional while-loop

-1
推荐指数
1
解决办法
1603
查看次数

标签 统计

c ×1

conditional ×1

matplotlib ×1

python ×1

while-loop ×1