-1

My code is (inside embedded MATLAB function):

function y=example(t)
y=rand(1,1)*t;

t is digital clock input (simulation block) with sampling time (1/1e6). The y also generates a random number sequence (uniform distribution) in 1/1e6 sampling time. But I need the sampling time output y should be in (1/1e3) time.

How can I do it?

rayryeng
  • 102,964
  • 22
  • 184
  • 193
viz
  • 15
  • 6

1 Answers1

0

I'm going to assume that your input t is a vector of time points defined with the sampling time of 1e-6. As such, going from 1e-6 to 1e-3 is a factor of 1000. All you have to do is take your t vector and sample every 1000th point. This will effectively create a digital clock input that has a sampling time of 1e-3 instead of 1e-6. In other words, all you have to do is this:

function y = example(t)
y = rand(1,1)*(t(1:1000:end));
rayryeng
  • 102,964
  • 22
  • 184
  • 193