matlab - Putting sampled values into a matrix- simulink -


how can put values matrix in simulink? example, if sampled sine wave every 0.5s, , put value fixed size matrix of size n. after matrix full, overwrite oldest values.

assuming talking using matrix if it's buffer, if have dsp blockset can use buffer block. otherwise pretty straight forward using matlab function block (see code below). if matrix constructed part of model, can passed second input matlab function block , (new element) insertion code modified appropriately.

function y = custom_buffer(u) %#codegen  persistent buffer next_index  buf_size = 1000;  % define initial values if isempty(buffer)     buffer = zeros(buf_size,1);     next_index = 1; end  % populate buffer buffer(next_index) = u;  % increment location write @ next time if next_index < buf_size     next_index = next_index + 1; else     next_index = 1; end  % populate output y = buffer; 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -