我有一个for循环,可将信号移位一定量并将其附加到数组中。我该如何对circshift节进行矢量化处理,这样就不需要使用for循环了?
fs_rate=10
len_of_sig=1; %length of signal in seconds
t=linspace(0,len_of_sig,fs_rate*len_of_sig);
y=.5*sin(2*pi*1*t);
for aa=1:length(y)
y_new(aa,:)=circshift(y,[1,aa+3]); %shifts signal and appends to array
end
plot(t,y_new)
PS:我正在使用Octave 4.2.2 Ubuntu 18.04 64bit
答案 0 :(得分:2)
在将/**
* Get the last offset for the given partitions. The last offset of a partition is the offset of the upcoming
* message, i.e. the offset of the last available message + 1. If messages have never been written
* to the the partition, the offset returned will be 0.
*
* <p>
* This method does not change the current consumer position of the partitions.
* <p>
* When {@code isolation.level=read_committed} the last offset will be the Last Stable Offset (LSO).
* This is the offset of the first message with an open transaction. The LSO moves forward as transactions
* are completed.
*
* @see #seekToEnd(Collection)
*
* @param partitions the partitions to get the end offsets.
* @return The end offsets for the given partitions.
* @throws org.apache.kafka.common.errors.AuthenticationException if authentication fails. See the exception for more details
* @throws org.apache.kafka.common.errors.AuthorizationException if not authorized to the topic(s). See the exception for more details
* @throws org.apache.kafka.common.errors.TimeoutException if the offsets could not be fetched before
* expiration of the configured {@code request.timeout.ms}
*/
@Override
public Map<TopicPartition, Long> endOffsets(Collection<TopicPartition> partitions)
用于基本移位之后,您可以使用gallery
创建一个圆形矩阵:
circshift
或者,如果您想知道其实现方式,请查看其源代码base_shift = 4;
fs_rate = 10;
len_of_sig = 1; # length of signal in seconds
t = linspace (0, len_of_sig, fs_rate*len_of_sig);
y = .5 * sin (2*pi*1*t);
y = gallery ("circul", circshift (y, [1 base_shift]));